javascript - How to restrict components in Google Maps geocoding API request URL -


i'm using google maps geocoding api given town/city's latitude , longitude. i'm trying restrict json response cities/towns within france. have gone through documentation found @ https://developers.google.com/maps/documentation/geocoding/start

however request returns me coordinates if location have entered not city. following json request url have built.

https://maps.googleapis.com/maps/api/geocode/json?address=abc&components=postal_town:abc|country:fr&key=api_key 

when use above request returns me following json although "abc" not valid town.

    {    "results" : [       {          "address_components" : [             {                "long_name" : "4",                "short_name" : "4",                "types" : [ "street_number" ]             },             {                "long_name" : "rue auber",                "short_name" : "rue auber",                "types" : [ "route" ]             },             {                "long_name" : "paris",                "short_name" : "paris",                "types" : [ "locality", "political" ]             },             {                "long_name" : "paris",                "short_name" : "paris",                "types" : [ "administrative_area_level_2", "political" ]             },             {                "long_name" : "Île-de-france",                "short_name" : "Île-de-france",                "types" : [ "administrative_area_level_1", "political" ]             },             {                "long_name" : "france",                "short_name" : "fr",                "types" : [ "country", "political" ]             },             {                "long_name" : "75009",                "short_name" : "75009",                "types" : [ "postal_code" ]             }          ],          "formatted_address" : "4 rue auber, 75009 paris, france",          "geometry" : {             "location" : {                "lat" : 48.87234979999999,                "lng" : 2.3300877             },             "location_type" : "approximate",             "viewport" : {                "northeast" : {                   "lat" : 48.8736987802915,                   "lng" : 2.331436680291502                },                "southwest" : {                   "lat" : 48.8710008197085,                   "lng" : 2.328738719708498                }             }          },          "place_id" : "chijh-qjtzzu5kcrrjwmr6brrzc",          "types" : [ "atm", "bank", "establishment", "finance", "point_of_interest" ]       },       {          "address_components" : [             {                "long_name" : "18",                "short_name" : "18",                "types" : [ "street_number" ]             },             {                "long_name" : "rue du 4 septembre",                "short_name" : "rue du 4 septembre",                "types" : [ "route" ]             },             {                "long_name" : "paris",                "short_name" : "paris",                "types" : [ "locality", "political" ]             },             {                "long_name" : "paris",                "short_name" : "paris",                "types" : [ "administrative_area_level_2", "political" ]             },             {                "long_name" : "Île-de-france",                "short_name" : "Île-de-france",                "types" : [ "administrative_area_level_1", "political" ]             },             {                "long_name" : "france",                "short_name" : "fr",                "types" : [ "country", "political" ]             },             {                "long_name" : "75002",                "short_name" : "75002",                "types" : [ "postal_code" ]             }          ],          "formatted_address" : "18 rue du 4 septembre, 75002 paris, france",          "geometry" : {             "location" : {                "lat" : 48.869747,                "lng" : 2.336408             },             "location_type" : "approximate",             "viewport" : {                "northeast" : {                   "lat" : 48.8710959802915,                   "lng" : 2.337756980291502                },                "southwest" : {                   "lat" : 48.8683980197085,                   "lng" : 2.335059019708498                }             }          },          "place_id" : "chijnxdnrtpu5kcrjlmrdxtjbqy",          "types" : [ "establishment", "finance", "point_of_interest" ]       }    ],    "status" : "ok" } 

how can rectify issue?


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -