Question

The problem is simple, in the documentation for the Geocoding API they say component filtering exists. (Source: https://developers.google.com/maps/documentation/geocoding/)

However, if I look at the JS documentation (https://developers.google.com/maps/documentation/javascript/geocoding), it doesn't seem to be implemented. I do however remember that google earlier used to have features implemented but not written about in their API, so I wonder if anyone knows how to achieve component filtering with the Google Maps Geocoding API?

Thanks!

Was it helpful?

Solution

The documentation seems to of implemented it now. Either way, here is the code:

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

Used to restrict results to a specific area. A filter consists of one or more of: route, locality, administrativeArea, postalCode or country. Only the results that match all the filters will be returned. Filter values support the same methods of spelling correction and partial matching as other geocoding requests. See Component Filtering in the Geocoding web service for further details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top