Adding thousands of Markers Google Map API V3
Asked Answered
P

2

6

I am currently putting together a demo application that needs to show 28,000 markers on a map without using any type of clustering. The problem is, adding the marker to the map for that many takes so long that the browser crashes! Here is the current process

-Retrieves map points from database including LAT and LONG (doesn't have to geocode) - for loop cycles through each of the returned values and does this:

  var marker = new google.maps.Marker({
                 position: point,
                 animation: google.maps.Animation.DROP,
                 map: map,
                 title: value.Title,
                 icon: icons['store']
             });

             google.maps.event.addListener(marker, 'click', function () {
                 var hidingMarker = currentPlace;
                 var slideIn = function (marker) {
                     $('#Name', info).text(place.Title);
                     $('#Phone', info).text(place.Description);
                     $('#Address', info).text(place.Proper_Address);
                     $('#LastSale', info).text("Last Sale:" + place.Last_Sale);
                     info.animate({ right: '0%' });
                 }

-the markers drop in and the user can click on any of them to see a little bit of information

Is there a more efficient way to do this so that showing 28,000 would be possible without having to cluster them? I have found some scripts people wrote to handle it before, but they are all for api V2. Any links or code is greatly appreciated! thanks!

Preiser answered 30/3, 2012 at 14:8 Comment(6)
What's the use case? How is 28000 markers useful to the user? Especially if they are supposed to select one to click on it. Far better to restrict your markers to the viewport and add/remove as necessary.Amoroso
I would say 28k of anything(no matter if adding a marker or making "boo") will crash any browser. So my suggestion: don't do it . FusionTables may be an optionSchleswigholstein
the use case is to plot all of the stores around the world color coordinate with different statistics. i created a small dot to replace the bigger marker that is default. This only has to work once, it will not ever be public for our usersPreiser
"It will not ever be public" opens questions over the Terms of Service.Amoroso
being a jerk to people pointing out things you may not have thought about is not really the best way to go about getting help from people.Samsara
Here's an example with 10,000 markers, more info here. Alternatively, Marker Clustering might be helpful.Tatting
B
3

In my experience, the only real way to show that many markers on the map at the same time is to use fusion tables (which does have some limitations and other challenges that need to be worked around). All other solutions for handling this many markers involve some form of clustering or will not work with wide zoom.

http://www.google.com/fusiontables/Home/

Brunson answered 30/3, 2012 at 14:18 Comment(3)
it looks like fusion tables will be my answer, thanks for sending me in the right directionPreiser
I've used Fusion Tables and it was designed for this type of problem.Etruscan
It isn't clear how Fusion Tables is an option. At any rate, Google is shutting it down in December 2019Varela
C
3

I assume you're not literally showing 28,000 on the screen at once? There will only be a subset visible?

If this is the case, why don't you just make a server request with the coordinate range you are displaying, then just plot those? There are map events that would allow you to know when the markers need to be updated, and you could avoid having too many objects in the browser at once.

Callus answered 30/3, 2012 at 14:13 Comment(1)
i really do need 28,000 on screen at once. I have created a customer marker that is a tiny dot that keeps the images from overlapping the best i can.Preiser
B
3

In my experience, the only real way to show that many markers on the map at the same time is to use fusion tables (which does have some limitations and other challenges that need to be worked around). All other solutions for handling this many markers involve some form of clustering or will not work with wide zoom.

http://www.google.com/fusiontables/Home/

Brunson answered 30/3, 2012 at 14:18 Comment(3)
it looks like fusion tables will be my answer, thanks for sending me in the right directionPreiser
I've used Fusion Tables and it was designed for this type of problem.Etruscan
It isn't clear how Fusion Tables is an option. At any rate, Google is shutting it down in December 2019Varela

© 2022 - 2024 — McMap. All rights reserved.