0
votes

How to correctly and clearly identify the address (e.g. Paris. France) of the coordinates using Google Reverse geocoding? Somewhere locations are marked by type “locality”, somewhere “administrative_area_level_2”, somewhere “administrative_area_level_3” etc. Is there any method to clearly determine the town or village or if the person is outside built-up areas?

Example: We send request: https://maps.googleapis.com/maps/api/geocode/json?sensor=true&language=en&latlng=55.6844952,37.6118719 Look for the city and In most cases get the following:

"address_components" : [
       {
          "long_name" : "Moscow",
          "short_name" : "Moscow",
          "types" : [ "locality", "political" ]
       },
…
},
    "place_id" : "...",
    "types" : [ "locality" ]
},

But sometimes we send request: https://maps.googleapis.com/maps/api/geocode/json?sensor=true&language=en&latlng=60.123062,64.78818 Look for the city and get:

"address_components" : [
       {
          "long_name" : " gorod Uray",
          "short_name" : "g. Uray",
          "types" : [ "administrative_area_level_2", "political" ]
       },
...
},
    "place_id" : "...",
    "types" : [ "administrative_area_level_2" ]
},

How the app can determine that in one case city is “locality”, and in other case city is “administrative_area_level_2” etc.

1
Im not sure I understand your question. For geolocation I have had success using Geocoder gem I would recommend that.srm

1 Answers

0
votes

In your example, Moscow is a capital and political center, that is why it is tagged as political; Gorod Uray is a not a city but a larger secondary administrative area, so it is tagged as administrative area.

This Type list from Google Maps API Places reference documents it clearly for the use of each type that composes the GeocoderAddressComponent object in searchResult.