Trying to utilize the geocoder for obtaining coordinates of the address below:
1945 Barton Street, Hamilton, ON, L8H2Y7
A search on Google Maps itself yields the address: . The geocode URL also returns results without any issues. http://maps.googleapis.com/maps/api/geocode/json?address=1945+BARTON+STREET,+HAMILTON,+ON,+L8H2Y7&sensor=false
However, when implementing the API (as shown below), it shows as not found.
Code: (works perfectly for other addresses)
if (geocoder) {
geocoder.geocode( {'address': fullAddress }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocoding failed: " + status + " " + fullAddress);
}
});
}
The correct address is actually "1945 Barton Street East, Hamilton, ON L8H2Y7, Canada", but maps and the direct URL can still locate it accurately, only the geocoder seems unable to.
Any thoughts on why this inconsistency might be occurring?
EDIT: I've identified the issue. It was a different address that couldn't be located by the geocoder or on Google Maps, but due to the asynchronous nature of the request, by the time the geocoder realized the address wasn't found, the loop had already changed to another address that could be found. Looks like I have some troubleshooting ahead..