开发者

Improving Google Maps Performance

I have to draw about 10000 line on Google Maps. So, it is spending too much time in dra开发者_Go百科w() 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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜