0
votes

For the Google Geocoding API (any version), is there any way to know if the response location (coordinate - latitude and longitude) is refereed to a 'house', a 'building' or none of them?

The idea here is to 'categorize' the location.

Given a list of human readable addresses (street name, number, zip, etc) I need to categorize each one of them as 'House', 'Building' or 'None'.

Request example:

https://maps.googleapis.com/maps/api/geocode/json?address=Dieciocho%2045%2C%20Santiago%2C%20Region%20Metropolitana&key={{key}}&components=country:CL

With the example the "location_type" is "ROOFTOP" (perfect accuracy) but even thou I don't see any address_component that can give me the information I need. Am I missing something?

I have read the api documentation (https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses) but didn't find anything helpful for the case.

Does anyone know how to achieve this result?

Thank you in advance

2

2 Answers

1
votes

For such a purpose, use Google Places API.

From JS v3 API, snippet is like this:

  var service = new google.maps.places.PlacesService(map);
  service.nearbySearch({
    location: new google.maps.LatLng(...),
    radius: 10,
    type: ['store']
  }, callback);

https://developers.google.com/maps/documentation/javascript/examples/place-search

1
votes

There is a way in the Geocoding API (and Places API) to tell whether a result is known (to Google Maps) to be a building of some sort or not.

In your example, "types" : [ "street_address" ] indicates the address is not tied to a specific building, in the API. There may actually be a building at that location in real life, it's just that the API does not know about it. So this is kinda telling you "don't know".

In the following example, "types" : [ "premise" ] the result indicates this is some kind of building... but as you can see, it's actually a cathedral: https://maps.googleapis.com/maps/api/geocode/json?latlng=-29.903018,-71.251052

For more fine grain distinctions, Places API Text Search lets you search for pretty much everything Google Maps does, and shows more types. These don't seem like they'll be enough to tell residential houses from other buildings though, may want to file a feature request for that.