4

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!

RyanG
  • 4,393
  • 2
  • 39
  • 64

1 Answers1

2

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

JQCorreia
  • 727
  • 6
  • 15
  • I have implemented it so that when the map is zoomed in a good amount and only a few buildings are on the screen; it only draws those buildings. This cuts down on lag tremendously, but if you are zoomed out and looking at the whole campus, the lag is still there. I have not tried to draw on a canvas yet; but I will see if it helps at all once I can get it working. – RyanG Apr 18 '11 at 12:22
  • Did it worked? Now i got curious because i have a similar implementation to do and would very much like the info. Thanks in advance – JQCorreia May 18 '11 at 16:14