0

I'm new to the google maps API. I've created a function which allows me to create pins inside a google map based off of their placeID. I have a long list of pins which I have to display but I've discovered that the map only shows the first 10 or 11.

It seems like its possible to set a delay on the function to get around only showing the first 10 according to other questions on stackoverflow but I don't understand how and my efforts just come up with errors. Is there a way to apply a timeout to my function to avoid running against the 10 marker limit?

function createPin(pinID) {
    service.getDetails({placeId: pinID }, function(place, status) {
          if (status === google.maps.places.PlacesServiceStatus.OK) {
            var marker = new google.maps.Marker({
                map: map,
                icon: pinIcon,
                position: place.geometry.location
            });
            google.maps.event.addListener(marker, 'click', function() {
                infowindow.setContent('<div class="infoWindow">' + place.name +'</div>');
                infowindow.open(map, this);
            });
          }
    });
}

/* Pins */

// Accenture
createPin('ChIJR6Ib2OwOZ0gRuWM8ipE_2Pk');
// Air BNB
createPin('ChIJwZfFge4OZ0gRz6mxPYx32Lc');
// ARUP
createPin('ChIJZedOre4OZ0gRwMvu-iJudQQ');
// Bank of Ireland
createPin('ChIJFyHFVZMOZ0gRO5Ld01Zz1XM');
/* long list of pins continues [...] */
patrick.altair
  • 351
  • 1
  • 2
  • 11
  • What's the origin of the limit? Is it the API? If so, can you link to the relevant docs? – Etheryte Aug 15 '16 at 12:02
  • @Nit I think the limit is due to time rather than a number. I came across this question which says there is generally a limit of around 9 to 11 but it doesn't say if they got that information from the docs. http://stackoverflow.com/questions/10762839/javascript-google-maps-displays-only-10-markers-out-of-100-is-there-a-limit – patrick.altair Aug 15 '16 at 12:39
  • related question: [OVER_QUERY_LIMIT in Google Maps API v3: How do I pause/delay in Javascript to slow it down?](http://stackoverflow.com/questions/11792916/over-query-limit-in-google-maps-api-v3-how-do-i-pause-delay-in-javascript-to-sl) – geocodezip Aug 15 '16 at 13:34

1 Answers1

0

The limit i don't think is on the Marker API, but on the "Place Details" API.

So what you can do is to cache in a file, or in database the info to all the places that you have and then you can freely create as many markers as you want.

Ibrahim
  • 2,034
  • 15
  • 22
  • I'm a beginner in javascript so please excuse my naïvety but it seems like I can store the marker info inside a JSON file and then call that from what I'm reading. Do you know how I would get the information to put inside the JSON file? At the moment I just had their placeID and then that provides the rest of the info like title and latitude longitude – patrick.altair Aug 15 '16 at 13:43
  • 1
    There are many ways to do this. Maybe do a PHP, Python or whatever language script that you run it once (or once a month?) which will iterate through all place IDs that you have and create a file with their info. After that, in your javascript you will have to load that json file through AJAX and place the markers. – Ibrahim Aug 18 '16 at 09:25