Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restricting geocoding to a country

I have seen that it is possible with the "static" to limit the scope of the search to a certain area (with components restrictions), I have also seen that in release 3.exp (will be 3.14) of the JavaScript API, a new class google.maps.GeocoderComponentRestrictions has appeared. I have not seen anywhere how this class is supposed to be used though. Does anyone have more information about this?

like image 292
Maurice Perry Avatar asked Feb 03 '26 01:02

Maurice Perry


1 Answers

It looks like this was answered over at Google Maps Geocoding API, feature from the API missing in their JS api (?), with formatting like:

geocoder.geocode( 
      { 'address': address, 'componentRestrictions':{'country':'GB'}}, 
function(results, status){
...   
});

The GeocoderComponentRestrictions parameters get passed with the componentRestrictions key.

like image 61
carpeliam Avatar answered Feb 06 '26 05:02

carpeliam