Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading markers on google maps dynamically on map move/drag/pan

Tags:

google-maps

I need to display a set of markers on a google map. In addition, I need to show additional markers, loaded dynamically, when the user pans the maps.

The number of markers could be in thousands, out of which 30-50 need to be displayed initially. Other markers need to be loaded and displayed only when user pans over an area that contains markers. I thought about using marker managers but i am not sure if markers can be fed to the marker manager dynamically. I want something more like this map. Notice how images load when you pan the map and garbage-collected when you pan away.

Marker clustering is not important but might be nice.

like image 233
Salman A Avatar asked Nov 06 '22 19:11

Salman A


1 Answers

I am doing this with clustering on a dataset of several thousand markers. This is how I'm doing it: When the 'moveend' event is fired, I get the bounds of the map and send an ajax request to the server. I get the markers from your DB which are in the bounds and send them back to the client. If you have questions about a specific part of the process, just let me know.

Also, with the Marker Manager, I believe that you can add markers dynamically.

like image 150
Chris B Avatar answered Nov 12 '22 15:11

Chris B