1

If you go to this demo (https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform), and enter the following:

  1. Petronas Twin Towers -> state will be "Wilayah Persekutuan Kuala Lumpur"
  2. Kuala Lumpur -> state will become "Federal Territory of Kuala
    Lumpur"

The 2nd one is controller by "regions" option (https://developers.google.com/places/web-service/autocomplete#place_types). I was expecting the state to be same but they are not.

I have also tried playing with &language=en but it doesn't help.

My ultimate goal is that I have Petronas Twin Towers in my DB, but I want to match it with state. My search autocomplete uses regions, which will return Federal Territory of Kuala Lumpur, and it won't match Wilayah Persekutuan Kuala Lumpur

One solution I could think of is to get the latitude and longitude, then find nearest records, but this is very slow to query.

Is there any other solution?

xomena
  • 31,125
  • 6
  • 88
  • 117
Victor
  • 13,010
  • 18
  • 83
  • 146

1 Answers1

2

Checking the state feature in Map Maker I can see that "Wilayah Persekutuan Kuala Lumpur" and "Federal Territory of Kuala Lumpur" are names in different languages.

https://mapmaker.google.com/mapmaker?gw=90&iwloc=0_0&dtab=history&cid=2534998778471541913

enter image description here

Not sure what logic is applied to get the name of the administrative area level 1 in places details. I guess it might be because the Petronas Twin Towers place was created in Google My Business and has Malay language assigned to it, so API detects the language of the place and applies this language to address components.

It looks like the reverse geocoding as you mentioned is the only reliable way to get the name in English:

https://maps.googleapis.com/maps/api/geocode/json?latlng=3.1579%2C101.7116&language=en&result_type=administrative_area_level_1&key=YOUR_API_KEY

xomena
  • 31,125
  • 6
  • 88
  • 117
  • Thanks. I also found this - http://stackoverflow.com/questions/36228611/google-places-api-details-language-not-working – Victor Mar 23 '17 at 16:40