Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 249
Onuray Sahin Avatar asked Jan 18 '26 14:01

Onuray Sahin


2 Answers

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.

like image 79
Onuray Sahin Avatar answered Jan 21 '26 06:01

Onuray Sahin


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.

like image 44
weakwire Avatar answered Jan 21 '26 05:01

weakwire