Onuray Sahin
Onuray Sahin

Reputation: 4135

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?

Upvotes: 3

Views: 3280

Answers (3)

Onuray Sahin
Onuray Sahin

Reputation: 4135

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.

Upvotes: 3

Kevin Parker
Kevin Parker

Reputation: 17216

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

Upvotes: 1

weakwire
weakwire

Reputation: 9300

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.

Upvotes: 2

Related Questions