Search code examples
javascriptgoogle-mapsgoogle-maps-api-3google-places-api

How to disable Atmosphere Data on Google AutocompleteService


Others have asked similar questions

However the difference is that they were using google.maps.places.Autocomplete which is the widget that builds an auto complete UI for you. As others have answered in the other questions, this widget has a method called setFields which you can specify which fields you want (so you can stop getting atmospheric data and stop getting charged for it)

However I am using the google.maps.places.AutocompleteService so I can build my own auto complete UI without using their widget.

However this service does not have a setFields method or any other way that I am aware of to specify the fields to stop getting charged for atmospheric data.

Is there a way to turn off atmosphere data with this?


Solution

  • OK I think I have it figured out,

    When you get the place ID from the auto complete service and then fetch more details, that is where you can specify the fields:

    const service = new google.maps.places.PlacesService(document.createElement('div'))
    service.getDetails({
      placeId: id,
      fields: ['address_components', 'geometry', 'name']
    }, callback)