Google Geocode API Giving Regional Data

1k Views Asked by At

I am working with GeoCoding API of Google.

I want to get English data always instead of regional language data.

I am calling this API link and taking formatted_address = लासुरगाव रोड, लसुर, महाराष्ट्र 423702, India from the first position of results key which is in Hindi from following data:

{
   "plus_code" : {
      "compound_code" : "W2H6+3M Harsul, Maharashtra, India",
      "global_code" : "7JFQW2H6+3M"
   },
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "लासुरगाव रोड",
               "short_name" : "लासुरगाव रोड",
               "types" : [ "route" ]
            },
            {
               "long_name" : "लसुर",
               "short_name" : "लसुर",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "औरंगाबाद",
               "short_name" : "औरंगाबाद",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "महाराष्ट्र",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "423702",
               "short_name" : "423702",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "लासुरगाव रोड, लसुर, महाराष्ट्र 423702, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 19.9279766,
                  "lng" : 75.011798
               },
               "southwest" : {
                  "lat" : 19.9276098,
                  "lng" : 75.0108685
               }
            },
            "location" : {
               "lat" : 19.9277932,
               "lng" : 75.01133329999999
            },
            "location_type" : "GEOMETRIC_CENTER",
            "viewport" : {
               "northeast" : {
                  "lat" : 19.9291421802915,
                  "lng" : 75.0126822302915
               },
               "southwest" : {
                  "lat" : 19.9264442197085,
                  "lng" : 75.0099842697085
               }
            }
         },
         "place_id" : "ChIJRS92AquJ2zsRGIY8TmId5OQ",
         "types" : [ "route" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Lasur",
               "short_name" : "Lasur",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Aurangabad",
               "short_name" : "Aurangabad",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "423702",
               "short_name" : "423702",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "Lasur, Maharashtra 423702, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 19.9365397,
                  "lng" : 75.0198626
               },
               "southwest" : {
                  "lat" : 19.9104756,
                  "lng" : 74.99952089999999
               }
            },
            "location" : {
               "lat" : 19.9282261,
               "lng" : 75.0114612
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 19.9365397,
                  "lng" : 75.0198626
               },
               "southwest" : {
                  "lat" : 19.9104756,
                  "lng" : 74.99952089999999
               }
            }
         },
         "place_id" : "ChIJqakxlFSI2zsRU2QZ0WNgCMQ",
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "423702",
               "short_name" : "423702",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Aurangabad",
               "short_name" : "Aurangabad",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Maharashtra 423702, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 19.9812906,
                  "lng" : 75.14881470000002
               },
               "southwest" : {
                  "lat" : 19.7257081,
                  "lng" : 74.7853344
               }
            },
            "location" : {
               "lat" : 19.8539262,
               "lng" : 74.9910112
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 19.9812906,
                  "lng" : 75.14881470000002
               },
               "southwest" : {
                  "lat" : 19.7257081,
                  "lng" : 74.7853344
               }
            }
         },
         "place_id" : "ChIJAVBUmAp43DsRAohUV0LQMO4",
         "types" : [ "postal_code" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Aurangabad",
               "short_name" : "Aurangabad",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Aurangabad, Maharashtra, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 20.6673799,
                  "lng" : 76.04805
               },
               "southwest" : {
                  "lat" : 19.37426,
                  "lng" : 74.58680009999999
               }
            },
            "location" : {
               "lat" : 19.8910826,
               "lng" : 75.1545381
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 20.6673799,
                  "lng" : 76.04805
               },
               "southwest" : {
                  "lat" : 19.37426,
                  "lng" : 74.58680009999999
               }
            }
         },
         "place_id" : "ChIJOV9BNoai2zsRtocWKbhGxs8",
         "types" : [ "administrative_area_level_2", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Maharashtra, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 22.028441,
                  "lng" : 80.890924
               },
               "southwest" : {
                  "lat" : 15.6024121,
                  "lng" : 72.659363
               }
            },
            "location" : {
               "lat" : 19.7514798,
               "lng" : 75.7138884
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 22.028441,
                  "lng" : 80.890924
               },
               "southwest" : {
                  "lat" : 15.6024121,
                  "lng" : 72.659363
               }
            }
         },
         "place_id" : "ChIJ-dacnB7EzzsRtk_gS5IiLxs",
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 35.513327,
                  "lng" : 97.39535869999999
               },
               "southwest" : {
                  "lat" : 6.4626999,
                  "lng" : 68.1097
               }
            },
            "location" : {
               "lat" : 20.593684,
               "lng" : 78.96288
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 35.513327,
                  "lng" : 97.39535869999999
               },
               "southwest" : {
                  "lat" : 6.4626999,
                  "lng" : 68.1097
               }
            }
         },
         "place_id" : "ChIJkbeSa_BfYzARphNChaFPjNc",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}

Is it possible to get English data only for every time as I don't want data in regional language?

Edited:

What I have tried recently?

  • Pass Accept-Language=en or Accept-Language=en-US in header but not working.
  • tried with language=en and hl=en but not working.
2

There are 2 best solutions below

1
Deep Rathod On
2
xomena On

I believe it might be kind of intended behavior. Google favor local language in Geocoding API responses in case of address local language has the same alphabet as user language.

This behavior is explained in the following blog article

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

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. For example, searching for an address in Brazil with user language set to English now returns “Avenida Paulista” rather than “Paulista Avenue”.

If the local language and user language use different alphabets, the Geocoding API will return the local name, transliterated into the Latin alphabet. In some cases, an English translation may be returned, for example if no transliteration is available. For example, searching for El Tahrir Square with user language set to Japanese now returns “El-Tahrir Square, Ismailia, Qasr an Nile, Cairo Governorate, エジプト” rather than “エジプト カイロ県 Qasr an Nile, タハリール広場” (the old result) or “ميدان التحرير، قصر النيل، محافظة القاهرة‬، مصر” (the local name).

Maybe Google detects that your IP address is located in India, so the response favor a local language.

In my case when I execute your sample request from my location in Spain I get response in English as following

https://maps.googleapis.com/maps/api/geocode/json?latlng=22.9997%2C72.6354&key=MY_API_KEY

{
  "plus_code":{
    "compound_code":"XJXP+V5 Ahmedabad, Gujarat, India","global_code":"7JJJXJXP+V5"
  },
  "results":[
    {
      "address_components":[
        {
          "long_name":"BRTS Corridor",
          "short_name":"BRTS Corridor",
          "types":[
            "route"
          ]
        },
        {
          "long_name":"Rabari Colony",
          "short_name":"Rabari Colony",
          "types":[
            "political","sublocality","sublocality_level_2"
          ]
        },
        {
          "long_name":"Amraiwadi",
          "short_name":"Amraiwadi",
          "types":[
            "political","sublocality","sublocality_level_1"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        },
        {
          "long_name":"380008",
          "short_name":"380008",
          "types":[
            "postal_code"
          ]
        }
      ],
      "formatted_address":"BRTS Corridor, Rabari Colony, Amraiwadi, Ahmedabad, Gujarat 380008, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.0048831,"lng":72.63708439999999
          },
          "southwest":{
            "lat":22.9996702,"lng":72.6353833
          }
        },
        "location":{
          "lat":23.0022759,"lng":72.6362362
        },
        "location_type":"GEOMETRIC_CENTER",
        "viewport":{
          "northeast":{
            "lat":23.0048831,"lng":72.6375828302915
          },
          "southwest":{
            "lat":22.9996702,"lng":72.6348848697085
          }
        }
      },
      "place_id":"ChIJ9UjW5mqGXjkR2mRics2aU4I",
      "types":[
        "route"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Rabari Colony",
          "short_name":"Rabari Colony",
          "types":[
            "political","sublocality","sublocality_level_2"
          ]
        },
        {
          "long_name":"Amraiwadi",
          "short_name":"Amraiwadi",
          "types":[
            "political","sublocality","sublocality_level_1"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        },
        {
          "long_name":"380038",
          "short_name":"380038",
          "types":[
            "postal_code"
          ]
        }
      ],
      "formatted_address":"Rabari Colony, Amraiwadi, Ahmedabad, Gujarat 380038, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.009061,"lng":72.6454679
          },
          "southwest":{
            "lat":22.9931311,"lng":72.6254739
          }
        },
        "location":{
          "lat":23.0019153,"lng":72.6343352
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.009061,"lng":72.6454679
          },
          "southwest":{
            "lat":22.9931311,"lng":72.6254739
          }
        }
      },
      "place_id":"ChIJaY70lGuGXjkRp_Y5g5vavs4",
      "types":[
        "political","sublocality","sublocality_level_2"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"380026",
          "short_name":"380026",
          "types":[
            "postal_code"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Ahmedabad, Gujarat 380026, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.0113677,"lng":72.6453252
          },
          "southwest":{
            "lat":22.9891871,"lng":72.60732229999999
          }
        },
        "location":{
          "lat":23.0044623,"lng":72.62575869999999
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.0113677,"lng":72.6453252
          },
          "southwest":{
            "lat":22.9891871,"lng":72.60732229999999
          }
        }
      },
      "place_id":"ChIJ89jUeXOGXjkRICMp0qh6yZg",
      "types":[
        "postal_code"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Amraiwadi",
          "short_name":"Amraiwadi",
          "types":[
            "political","sublocality","sublocality_level_1"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Amraiwadi, Ahmedabad, Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.0137105,"lng":72.645556
          },
          "southwest":{
            "lat":22.989467,"lng":72.61277
          }
        },
        "location":{
          "lat":22.9996728,"lng":72.635381
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.0137105,"lng":72.645556
          },
          "southwest":{
            "lat":22.989467,"lng":72.61277
          }
        }
      },
      "place_id":"ChIJJTsGyhKGXjkR96JPXxPnU-4",
      "types":[
        "political","sublocality","sublocality_level_1"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Ahmedabad, Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.1378156,"lng":72.7053737
          },
          "southwest":{
            "lat":22.9028759,"lng":72.4541115
          }
        },
        "location":{
          "lat":23.022505,"lng":72.5713621
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.1378156,"lng":72.7053737
          },
          "southwest":{
            "lat":22.9028759,"lng":72.4541115
          }
        }
      },
      "place_id":"ChIJSdRbuoqEXjkRFmVPYRHdzk8",
      "types":[
        "locality","political"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Ahmedabad, Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.50846,"lng":72.84009999999999
          },
          "southwest":{
            "lat":21.9817599,"lng":71.83994
          }
        },
        "location":{
          "lat":23.022475,"lng":72.5715183
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.50846,"lng":72.84009999999999
          },
          "southwest":{
            "lat":21.9817599,"lng":71.83994
          }
        }
      },
      "place_id":"ChIJIxcnN0CEXjkRobQIMyNYLpI",
      "types":[
        "administrative_area_level_2","political"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":24.705709,"lng":74.4764881
          },
          "southwest":{
            "lat":20.127954,"lng":68.162834
          }
        },
        "location":{
          "lat":22.258652,"lng":71.1923805
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":24.705709,"lng":74.4764881
          },
          "southwest":{
            "lat":20.127954,"lng":68.162834
          }
        }
      },
      "place_id":"ChIJlfcOXx8FWTkRLlJU7YfYG4Y",
      "types":[
        "administrative_area_level_1","political"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":35.513327,"lng":97.39535869999999
          },
          "southwest":{
            "lat":6.4626999,"lng":68.1097
          }
        },
        "location":{
          "lat":20.593684,"lng":78.96288
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":35.513327,"lng":97.39535869999999
          },
          "southwest":{
            "lat":6.4626999,"lng":68.1097
          }
        }
      },
      "place_id":"ChIJkbeSa_BfYzARphNChaFPjNc",
      "types":[
        "country","political"
      ]
    }
  ],
  "status":"OK"
} 

So, in order to get English results you should send requests from a server located outside your country, e.g. from Europe or try to convince Google that you are located outside India (maybe using VPN).

I hope this helps!

Update

The https://maps.googleapis.com/maps/api/geocode/json?latlng=19.9276734%2C75.0116544&key=MY_API_KEY also gives results in Hindi for me.

Note that the type of result is "route" and place Id is ChIJRS92AquJ2zsRGIY8TmId5OQ.

If I open this place ID in Geocoder tool the text is also in Hindi

https://google-developers.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJRS92AquJ2zsRGIY8TmId5OQ

If you execute place details request https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJRS92AquJ2zsRGIY8TmId5OQ&key=YOUR_API_KEY you will see in response direct link on Google maps for this place

https://maps.google.com/?q=%E0%A4%B2%E0%A4%BE%E0%A4%B8%E0%A5%81%E0%A4%B0%E0%A4%97%E0%A4%BE%E0%A4%B5+%E0%A4%B0%E0%A5%8B%E0%A4%A1,+%E0%A4%B2%E0%A4%B8%E0%A5%81%E0%A4%B0,+%E0%A4%AE%E0%A4%B9%E0%A4%BE%E0%A4%B0%E0%A4%BE%E0%A4%B7%E0%A5%8D%E0%A4%9F%E0%A5%8D%E0%A4%B0+423702,+India&ftid=0x3bdb89ab02762f45:0xe4e41d624e3c8618

The text in Google maps is also in Hindi.

It looks like place with id ChIJRS92AquJ2zsRGIY8TmId5OQ that represents a route indeed has a data issue on Google side.

I think the only way to fix it is contacting Google Maps API support team. Hopefully they can help with this data issue.