How do I filter Google Maps results for a specific region?

Posted on

Question :

I have a route system that captures user data and maps routes on the map:

    'address': endereco + ', Brasil', 
    'region': 'BR' 
}, function (results, status) {}

The problem is that it is returning addresses from all over Brazil and in some cases even out of it.

How do I configure the script to search only in a specific city? Ex: Search only locations that are within Belo Horizonte.


Answer :

You should use the componentRestrictions option and set the filter for the administrativeArea field, documentation here .

In this case your code would look like this:

    'address': endereco,
    'region': 'BR',
    'componentRestrictions': {
        'country': 'BR',
        'administrativeArea': 'Belo Horizonte'
}, function (results, status) {




Leave a Reply

Your email address will not be published. Required fields are marked *