简体   繁体   中英

Improving Google Maps Performance

I have to draw about 10000 line on Google Maps. So, it is spending too much time in draw() 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM