Optimal way to draw lines and polygons dynamically on Nutiteq map? - android

I have been working on nutiteq maps, and I need to draw a trace over map, as my location changes, but it should be with different width(5m, 10m) and need to calculate where its overlapping itself. I draw lines dinamicly with line.setVertexList(arr_lat_long), but I think that this isn't an good approach to do this job. Think to draw them like a polygons, because then will calculate overlapping with JTS. But it will be very slow operation :/. Is there an another way to draw over the map, some other paint tool or lib to help me. The purpose is to fill some area with these traces..
Thanks

Related

osmdroid trying to display many polygons overlay

i need to overlay many (clickable) polygons on the map (over 5000), so the normal Polygon overlay is slow in performance.
My idea is to create a custom bitmap overlay, drawing on a bitmap canvas only polygons that are inside current bounding coordinates, ignoring all drawing for polygons outside.
Moreover i would to redraw the overlay only when the user has finished to zoom or panning, not during this operation, for performance reasons.
Can someone please point some help to me?
Thanks.
In your case, Bounding box test is a good solution when a lot of polygons are completely outside the viewbox.
You can subclass the Polygon, add a bounding box attribute, and override the draw method to first test if this bounding box is completely outside the viewbox.
No need to draw on a bitmap canvas.
Now, if the user zoom-out, he will have all polygons inside the viewbox: back to the initial issue... A solution could be to handle levels of details. Maybe using the DouglasPeucker reducer (available in OSMBonusPack utils).

osmdroid draw polygon on map

I want to draw something like this:
gooogle maps example
but using osmdroid with OpenStreetMaps.
I have a set of GPS points prepared but I cannot find ay working example
Has anyone done this?
PathOverlay will not do the job properly: it has been optimized for drawing lines, and this is causing issues when using it for filled polygons (when the polygon is partly inside the view, and partly outside).
You can use the OSMBonusPack Polgon overlay.
A PathOverlay will give you the polygon. You may have to extend PathOverlay to create the fill color.

Android: Numerous overlays slowing down map movement

I have numerous Overlays added to a MapView. When I move, zoom in, or zoom out of the MapView the overlays cause a significant lag before the map responds to the action. Is there any way I can minimize this delay?
I saw that someone else suggested combining all the overlays into one large overlay for a similar problem. If something like that would work, how would I combine my array of overlays into a single overlay?
I also saw that it may improve performance to draw all the lines specified in the overlays on a bitmap and then overlay the bitmap instead. If this is the best option, then how would I go about implementing it?
Any help would be greatly appreciated. If you need any more information or code, then please ask!
I have numerous Overlays added to a MapView. When I move, zoom in, or zoom out of the MapView the overlays cause a significant lag before the map responds to the action. Is there any way I can minimize this delay?
Have fewer and less-complicated overlays. Use Traceview to determine exactly where your problem is. If it is that one of your existing draw() methods is slow, you will need to fix that before worrying about combining overlays. If the excess time seems to be in overlay management in MapView, then consolidating your overlays into fewer overlays may have benefit.
how would I combine my array of overlays into a single overlay?
Refactor the code into a single overlay class. Beyond that, we cannot help you, since we do not know much of anything about your overlays, other than that they are "numerous".
If this is the best option, then how would I go about implementing it?
Create a bitmap-backed Canvas, draw your lines on it, then draw the resulting Bitmap in your overlay in draw(), I presume.

Improving Google Maps Performance

I have to draw about 10000 line on Google Maps. So, it is spending too much time in draw() method. Moving on map becomes very laggy. Is there any way to cache drawing or can I draw just the part of map / canvas which is currently seen on screen?
drawing 10000 lines will never get lag free. I'm guessing you connect points.
Here is an implementation of point Clustering in mapView and also renders the visible ones if you want. So you can draw lines to the clustered points.
Now I can draw all 10000 lines without any lag. It is all about designing draw() method carefully. I moved some object creating operations (like Path, Point) out of draw(). I saw that especially projection.toPixels(geoPoint, point); is very expensive operation. Finally I set an alpha constant which holds the pixel value of finger movement. And it only draws when pixelX or pixelY movement is bigger than alpha.
Have a look at this post, it suggests drawing your lines into a shape then drawing that to the mapview.
Here: Cache whats being draw on MapView in Android
Just a suggestion on this one, you may want to try saving the MapView as a bitmap then render that instead (depending on your situation).
Here: Save MapView as a Bitmap

Cache whats being draw on MapView in Android

I am developing an app for my Universities campus that displays the campus in a MapView; then using geopoints draws the outlines of the buildings on campus on the mapView using the draw method a class that extents Overlay. There are about 50-60 buildings being drawn, resulting in a very laggy map as the draw method constantly gets drawn over and over.
I have looked into my problem and I have found some people mentioning drawing the buildings on a canvas, but I have found no good examples or info on how to go about implementing this. Can anyone point me in the right direction on how to reduce the map's lag? The map looks very nice but the lag just kills its usefulness.
Thanks!
If you have all the points organized into polygons you can draw polygons on a canvas and then draw it on an Overlay. That i think would be quicker.
Also you can always do some calculation about what part of the building need to be redrawn for the next position and just change that part of the Canvas.
If you moved (X,Y) pixels from an earlier position, shift the existing canvas into the new position and just draw the new things that appear on map.
This is not the optimal solution of course because this kind of caching wouldn't work with the zoom.
Hope it helped somehow!
JQCorreia

Categories

Resources