Google Geocoder Return response in French need in english

Oct 31 2019 5:02 AM
Google Maps Geocoder Returns response for canada in french, while I need the response in english
 
My Project having a dropdown of states/Province of canada, I select those state based on zip code find out the city or state by google.geocoder
 
While i am using for canada geocoder.geocode response in french while I need the response in english.
Code in JS :
  1. var geocoder = new google.maps.Geocoder();  
  2. geocoder.geocode({ 'address'"G1B0A3, Canada" }, function (results, status) {  
  3. if (status == google.maps.GeocoderStatus.OK) {  
  4. if (results.length >= 1) {  
  5. for (var ii = 0; ii < results[0].address_components.length; ii++) {  
  6. var types = results[0].address_components[ii].types.join(",");  
  7. if (types.includes("locality")) {  
  8. $("#City").val(results[0].address_components[ii].long_name);  
  9. city = results[0].address_components[ii].long_name;  
  10. }  
  11. if (types == "administrative_area_level_1,political") {  
  12. $(".StateClass option").each(function () {  
  13. if ($(this).text().toUpperCase() == results[0].address_components[ii].long_name.toUpperCase()) {  
  14. if (typeof (state) != "undefined") {  
  15. state = $(this).val();  
  16. $(".StateClass").val($(this).val());  
  17. }  
  18. else {  
  19. $(this).attr('selected'true);  
  20. state = $(this).val();  
  21. $(".StateClass").val(state);  
  22. }  
  23. }  
  24. });  
  25. }  
  26. }  
  27. }  
  28. }  
  29. }  
Return Response :
 
{ "results" : [ { "address_components" : [ { "long_name" : "G1B 0A3", "short_name" : "G1B 0A3", "types" : [ "postal_code" ] }, { "long_name" : "Beauport", "short_name" : "Beauport", "types" : [ "political", "sublocality", "sublocality_level_1" ] }, { "long_name" : "Québec", "short_name" : "Québec", "types" : [ "locality", "political" ] }, { "long_name" : "Communauté-Urbaine-de-Québec", "short_name" : "Communauté-Urbaine-de-Québec", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Québec", "short_name" : "QC", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Canada", "short_name" : "CA", "types" : [ "country", "political" ] } ], "formatted_address" : "Quebec City, QC G1B 0A3, Canada", "geometry" : { "bounds" : { "northeast" : { "lat" : 46.9396628, "lng" : -71.2022018 }, "southwest" : { "lat" : 46.9154927, "lng" : -71.24334639999999 } }, "location" : { "lat" : 46.92634260000001, "lng" : -71.2211823 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 46.9396628, "lng" : -71.2022018 }, "southwest" : { "lat" : 46.9154927, "lng" : -71.24334639999999 } } }, "place_id" : "ChIJpS4Sv3q7uEwRz9gVYd5OSvs", "types" : [ "postal_code" ] } ], "status" : "OK" }
 
Expect Response :
{ "long_name" : "Quebec", "short_name" : "Quebec", "types" : [ "locality", "political" ] },

Answers (2)