Search code examples
google-mapsgoogle-maps-api-3geocodinggoogle-geocoder

Google Maps API v3 Geocoding Status is OK even if geocoded street doesn't exist


I just discovered a strange behavior in Google Maps API V3, and more specifically with its Geocoding tool.
Here is an exemple : This is how I geocode my addresses :

var request = HttpWebRequest.Create(@"http://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&sensor=false");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

where address is a varible with a full address entered by the user.

When the address is a valid one, response.StatusCode is OK, which means, according to the documentation, "that no errors occurred; the address was successfully parsed and at least one geocode was returned."
But when the try to geocode this adress :

15 StreetWhoDoesntExist, 69009 LYON

the StatusCode is OK and the latitude / longitude returned is the center of the city (in this example, LYON, which is a real French city and its corresponding zipcode, 69009).

Is this behaviour normal ? When I entered the same address in Google Maps, it told me it can't find this address (which is the "good" behavior). So, how can I reproduce it with GMaps API in order to it refuses addesses with an unknown street name, even if the associated city and/or zipcode exists ?

Thanks in advance !


Solution

  • API CALL

    Result:

         "partial_match" : true,
         "types" : [ "sublocality", "political" ]
    

    So I'd check those two or at least the types to determine if it found the actual street address.