Maurice Perry
Maurice Perry

Reputation: 32831

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?

Upvotes: 3

Views: 4016

Answers (1)

carpeliam
carpeliam

Reputation: 6769

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.

Upvotes: 9

Related Questions