0

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?

JD Isaacks
  • 56,088
  • 93
  • 276
  • 422
  • 3
    The Autocomplete Service class does not return any place information and that includes atmosphere data. You get these by doing a Place Details request. Use session tokens so you don't get charged for Autocomplete requests if you use Places Details. See the [docs](https://developers.google.com/maps/documentation/javascript/place-autocomplete#place_autocomplete_service). – MrUpsidown May 02 '23 at 19:36

1 Answers1

1

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)
JD Isaacks
  • 56,088
  • 93
  • 276
  • 422