0
votes

I'm trying to use the geocoder to get co-ordinates for the following address:

1945 Barton Street, Hamilton, ON, L8H2Y7

Searching the address on google maps itself finds the address: http://g.co/maps/5axb5. Using the geocode url also returns fine. http://maps.googleapis.com/maps/api/geocode/json?address=1945+BARTON+STREET,+HAMILTON,+ON,+L8H2Y7&sensor=false

However, when I use the api (my code below), it returns not found.

image

Code: (this works fine for several other addresses I'm searching)

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 "actual" address is "1945 Barton Street East, Hamilton, ON L8H2Y7, Canada", but maps and the direct url still find the place fine, only the geocoder doesn't.

Any ideas as to why this might be happening?

EDIT: I figured it out. It was a different address that it legitimately couldn't find (not on google maps or using the geocoder), but because the request was being done asynchronously by the time the geocoder realized it couldn't find the address, the loop had already changed the address value to another address which it could find. Seems like I've got some work ahead of me..

1

1 Answers

1
votes

it's strange because it work's on my live demo check this

Live Demo

Do you have more code somewhere??

Update

I test the service with the plus symbol, and even without canada and still worked

here's examples