My simple app has been working quite well until a client reported a bug as mentioned in the title. Google return sometime accent-removed result :
{
"long_name" : "Hanoi",
"short_name" : "Hanoi",
"types" : [ "administrative_area_level_1", "political" ]
}
And accented one:
{
"long_name" : "Hà Nội",
"short_name" : "Hà Nội",
"types" : [ "administrative_area_level_1", "political" ]
}
I have tried applying API key (with language = french) but no luck.
As the result, my logic to group address by city , district failed!
BTW, do you guys have any good hints to automatically group address into district, city, country using data from google geocode or any other provider
Thank you
If you want French as a language of your resulting data you have to mention that in your language parameter of your request.
However, to group addresses into district city and country you can use the following API request.
https://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&language=fr&key=API_KEY
In the response your district will be administrative_area_level_2 the states will be administrative_area_level_1 while the country will be the country parameter.
I am posting the JSON for the above request.
{
results: [1]
0: {
address_components: [5]
0: {
long_name: "Winnetka"
short_name: "Winnetka"
types: [2]
0: "locality"
1: "political"
-
}-
1: {
long_name: "New Trier"
short_name: "New Trier"
types: [2]
0: "administrative_area_level_3"
1: "political"
-
}-
2: {
long_name: "Comté de Cook"
short_name: "Comté de Cook"
types: [2]
0: "administrative_area_level_2"
1: "political"
-
}-
3: {
long_name: "Illinois"
short_name: "IL"
types: [2]
0: "administrative_area_level_1"
1: "political"
-
}-
4: {
long_name: "États-Unis"
short_name: "US"
types: [2]
0: "country"
1: "political"
-
}-
-
formatted_address: "Winnetka, Illinois, États-Unis"
geometry: {
bounds: {
northeast: {
lat: 42.1282269
lng: -87.71081629999999
}-
southwest: {
lat: 42.0886089
lng: -87.7708629
}-
}-
location: {
lat: 42.10808340000001
lng: -87.735895
}-
location_type: "APPROXIMATE"
viewport: {
northeast: {
lat: 42.1282269
lng: -87.71081629999999
}-
southwest: {
lat: 42.0886089
lng: -87.7708629
}-
}-
}-
place_id: "ChIJW8Va5TnED4gRY91Ng47qy3Q"
types: [2]
0: "locality"
1: "political"
-
}-
-
status: "OK"
}