SheppardDigital
asked on
Google Maps API not showing all marks
I'm just wondering if someone could help me out with a map issue.
I've put a google map on a page using the API, and I'm trying to put points on the map using UK postcodes. I think I've done it correctly but the map is only showing a handful of markers.
Could someone have a look and tell me where I'm going wrong?
http://theappdevelopers.webdevsvr.com/ploink/charity/map/
I've put a google map on a page using the API, and I'm trying to put points on the map using UK postcodes. I think I've done it correctly but the map is only showing a handful of markers.
Could someone have a look and tell me where I'm going wrong?
http://theappdevelopers.webdevsvr.com/ploink/charity/map/
ASKER
I've signed up for a key for google maps, but the map still doesn't seems to be working how I'd like it to?
If I log into the google api site, I can see 1 active api for google maps v3, and I've put the API key into the URL. If you view the source hopefully you'll see the key.
If I log into the google api site, I can see 1 active api for google maps v3, and I've put the API key into the URL. If you view the source hopefully you'll see the key.
Can you try this code to make sure what the problem is? Check the console (with F12 in IE) for output.
Actually, looking at the GeoCoding Usage Limits, I only see a relaxed policy for Business accounts, nothing about the limit of 11 or 12 that I'm seeing on your site, but also nothing about a relaxed policy for normal accounts.
You haven't commented on my previous solution but I assume that the trickle is taking too long for you. Have you considered caching the lat/lng for the postcodes? I'm not sure it would be 100% legal looking at the documentation, although you are ultimately only using the locations to put markers on a map. The simplest way would be to use the trickle code to get the coordinates and put them in a javascript array, but if the postcodes are currently stored server side (and could be changed) you could make some system to determine the coordinates for new postcodes which should be less prone to exceeding the limit and even if it does, after some time it would solve itself as the new postcodes are added in 'batches'.
for (i = 0; i < postcodes.length; i++) {
geocoder.geocode( { 'address': postcodes[i] + ',UK'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log('OK, results.length = ' + results.length);
if (results.length > 0) {
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
}
} else {
console.log('ERR, status = ' + status);
}
});
}
I'm still getting the error OVER_QUERY_LIMIT, but then I assume the key only works when used from your website...Actually, looking at the GeoCoding Usage Limits, I only see a relaxed policy for Business accounts, nothing about the limit of 11 or 12 that I'm seeing on your site, but also nothing about a relaxed policy for normal accounts.
You haven't commented on my previous solution but I assume that the trickle is taking too long for you. Have you considered caching the lat/lng for the postcodes? I'm not sure it would be 100% legal looking at the documentation, although you are ultimately only using the locations to put markers on a map. The simplest way would be to use the trickle code to get the coordinates and put them in a javascript array, but if the postcodes are currently stored server side (and could be changed) you could make some system to determine the coordinates for new postcodes which should be less prone to exceeding the limit and even if it does, after some time it would solve itself as the new postcodes are added in 'batches'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
It seems caching is more than likely the best option like you say.
I've previously developed an api to return the longitude and latitude for a postcode that's based on the post code database that you can download. I could probably use that in combination with the google maps to get something working.
It seems caching is more than likely the best option like you say.
I've previously developed an api to return the longitude and latitude for a postcode that's based on the post code database that you can download. I could probably use that in combination with the google maps to get something working.
Open in new window
Of course now it takes a while before all markers are there but at least it doesn't stop at some undetermined point. The exact interval (100 ms now) could be played with, I'm not sure what the minimum is but maybe it's not wise to try and go too low as it might start failing again at some point.Have you researched the possibility of obtaining a license so you can do more (if not unlimited) calls? This is often how things like that work, although I haven't looked at it for this service.