开发者

Cache whats being draw on MapView in Android

开发者 https://www.devze.com 2023-02-24 21:57 出处:网络
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

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开发者_C百科 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号