Cache whats being draw on MapView in Android

て烟熏妆下的殇ゞ 提交于 2019-12-07 09:41:22

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/5677961/cache-whats-being-draw-on-mapview-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!