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.
Related
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
I have checked a lot of SO questions but none really answered it.
I am looking to add google map with animated markers. This means sprite display 3-4 frames while fixed at the location and while moving.
I thought about using AnimationDrawable but that didn't work. The other 2 solutions I have in mind are:
1-Use marker.setPosition and marker.setIcon in a "loopy handler". Inclined to use this but for some reason I feel it is an over kill especially that I may have 100 Markers
2-Add SurfaceView on the map and draw bitmaps using LocationToPixels functionality of the map. But that may be cumbersoms when gestures are moving.
Do you recommend any of the above or even a new solution? Please justify why so it is not an oppinionated answer.
Thank you
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
I'm building a map with a few dozen OverlayItems in a single ItemizedOverlay. My map is made to be viewed very close up (about zoom level 18+), with the OverlayItems in very close proximity to one another. The map looks good when zoomed in. However, if the user zooms out the icons begin to overlap and everything looks incredibly junky.
Is there a way to control the OverlayItem icon size so that it scales with the map? If not, is there a way to hide the icons once a specific zoom level is reached? Any other suggestions on how to approach this problem?
Joshc, fegruior, You folks may want to check out how Geobeagle does it. Specifically, this file: http://code.google.com/p/geobeagle/source/browse/trunk/GeoBeagle/src/com/google/code/geobeagle/activity/map/OverlayManager.java
They manage two overlays, one for when you're zoomed out, and one for when you're zoomed in.
Theoretically, you could have n (however many zoom levels there are) overlays that all have differently sized icons, and swap the visible one out as you zoom in and out. This could get heavy on the processing, but whether that's something you want to do is a decision you would need to make.
If a user does a "pinch zoom" on the map, my overlays don't properly size until the end. This has been noted in other posts, so i assume it is a known issue.
Problem is, my client finds it totally unacceptable, as I am tasked with making the android app look as good as the iphone version.
Is there any way to correct this, even if it is a horrible hack? For instance, can I subclass the mapview and handle drawing or override some other method?
The common solution is to not draw overlay during zoom animation.
UPDATED:
Sorry, I've confused zoom and move.
The problem with zoom is that you can't rely on zoom level. Instead you need to draw your overlay based on MapView.getProjection().