I'm using a great jQuery plugin called GMaps3 to display a map on a website. I'm trying to add markers with the .addMarker method (I only know the address, not the lat and long) but it only adds 11 markers max in my example.
I am trying to figure out why certain markers are not displayed while others are.
Update: The number of markers shown is not constant. I edited one of the address strings (thanks NgM) to make it more specific and the number of markers shown increased to 11. Other markers won't show up though, even if they are non-ambiguous. It's the first dozen or so which show up.
Here is an online example to show the problem.
I had the exact same problem and I finally figured out how to solve it. The problem is occurring because geocoding does not allow a lot of simultaneous requests. So this is where a the setInterval() javascript method comes in handy.
Just add something like this to your code:
counter = 0,
timer = setInterval(function () {
createMarkers(map, postcodes);
counter++
if (counter3 === postcodes.length) {
clearInterval(timer);
}
}, 1000);
The CreateMarkers() function is where the markers are created from an Array. So after each postcode has been geocoded and applied to the map the script waits 1 second and then continues with the next postcode.
I hope this helps, I spent ages wondering why it only let 11 markers on the map at one time!
This is because some of your addresses do not resolve to a specific address.
You have entries like: "Campus Pappelallee, 14406 Potsdam, Germany"
Google Maps, when you search for this address, has no way of knowing where you want it to select. There are over 1,500 suggestions.
The reason you see markers for addresses like:
Boulevard James-Fazy 15, 1201 Genève, Switzerland
Is because Google Maps can find that address and that search only returns one result (IE the exact place you had in mind).
For all addresses that Google Maps can't resolve correctly and you know it exists at the address you listed then simply use the long/lat instead of address. You said you do not happen to know a more specific address though for these entries so I suggest you spend some time figuring out where it is exactly you want the marker to be placed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With