-1

I used google map api to get a street address of a house in Madrid, Spain. Then I got the following for place_administrative_area_level_1.

place_administrative_area_level_1_short: Comunidad de Madrid place_administrative_area_level_1_long: Comunidad de Madrid

Then I saved those details to database. Now I want to search the addresses I saved from Madrid. So from front end, again I search google place api by Madrid, Spain. Then google returns me the following for place_administrative_area_level_1.

place_administrative_area_level_1_short: Community of Madrid place_administrative_area_level_1_long: Community of Madrid

See the difference? Now I can't use this string to search my database as it has different value. In both cases, I am sending language=en. So why it is returning different values for this address field? The only difference is that, for the 1st one, I used like a street address of a house in Madrid. In second instance, I used like Madrid, Spain only. But in both cases, it should return the same value for place_administrative_area_level_1. Because of this, I can't search my database by a single value.

xomena
  • 31,125
  • 6
  • 88
  • 117
Shehan Simen
  • 1,046
  • 1
  • 17
  • 28
  • 1
    Did you read Google Maps Terms of Service about storing data from their various APIs? – MrUpsidown Jan 31 '19 at 11:47
  • @MrUpsidown Can u explain me how did I get negative points for this? what are the reasons for that? – Shehan Simen Jan 31 '19 at 23:47
  • @MrUpsidown You didn't answer my question. I am new to Google Maps API. Thast is why I am asking this question. I haven't seen this questions asked my others. If you know the answer or reason, please say it properly – Shehan Simen Jan 31 '19 at 23:50
  • I know I didn't answer your question. This was only a comment about the fact that you are storing Google content in your database. Please read [3.2.4 Restrictions Against Misusing the Services](https://cloud.google.com/maps-platform/terms/#3-license). – MrUpsidown Feb 01 '19 at 08:51
  • Possible duplicate of [Get place\_id of address\_components](https://stackoverflow.com/questions/43499392/get-place-id-of-address-components) – Gajus May 28 '19 at 21:05

1 Answers1

3

This is because of localization policy applied by Geocoding API web service. You can read about it in the following post:

https://mapsplatform.googleblog.com/2014/11/localization-of-street-addresses-in.html

Street-level addresses returned by the Google Maps Geocoding API now favor the local language, while keeping the address understandable as much as possible for both a user who only reads the requested language as well as locals.

If the local language and user language both use the same alphabet, the Geocoding API will now return the local names for the streets and localities.

In your examples the first request searches street level address, so you get a Spanish name for address component administrative_area_level_1 Comunidad de Madrid as mentioned above.

The second request is not a street level address, so the aforementioned policy is not applied and you get a name according to the language parameter which is English Community of Madrid.

I believe you might be strongly interested in the following feature request:

Add place_id in each address_components

Once this feature request is implemented you will be able to compare place ids instead of the names in address components.

I hope this addresses your doubt.

Community
  • 1
  • 1
xomena
  • 31,125
  • 6
  • 88
  • 117
  • Thanks a lot for your answer. it is very helpful. Yes I am very interested in that feature request. I don't understand why it is not there at the first place. How the users are supposed to compare administrative_area_level_1 if it is returning in different languages? Hopefully I can expect this fixed in this year – Shehan Simen Feb 01 '19 at 00:00