google-mapsgoogle-maps-api-3

Avoid local business listing in google map geocomplete?


I am using google map api v3 for my map. I need to avoid business results from results listing.

attaching a screenshot for reference.

The picture shows all the business related result also. I need the results to be filtered as places. Is it possible?

Google map


Solution

  • According to the documentation you can filter results:

    An options argument, which can contain the following properties:

    An array of types specifies an explicit type or a type collection, as listed in the supported types below. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the geocode and establishment types, but note that this will have the same effect as specifying no types. The supported types are:

    geocode instructs the Places service to return only geocoding results, rather than business results.

    address instructs the Places service to return only geocoding results with a precise address.

    establishment instructs the Places service to return only business results.

    the (regions) type collection instructs the Places service to return any result matching the following types:

    1. locality
    2. sublocality
    3. postal_code
    4. country
    5. administrative_area1
    6. administrative_area2

    the (cities) type collection instructs the Places service to return results that match either locality or administrative_area3.

    Example:

    var input = document.getElementById('searchTextField');
    var options = {
      types: ['(cities)']
    };
    
    autocomplete = new google.maps.places.Autocomplete(input, options);