Irm working with the Javascript API for Google Maps to retrieve a nearby places request then get somes details from the places returned.
The nearby places request works well, but when I'm trying to get the details, the url fields parameter seems malformed, so google is returning all the fields and I'm billed for it...
I pointed it out by searching into the network console, the url requested is:
And since the november update, for sure, it sends to me a thousand of deprecated open_hours.open_now error (because of the fact that all fields is returned, even those deprecated), but I guess this will be solved when my principal issue will be solved.
I'm using getDetails in two places in my code with two different fields parameters, so I stored these in two distinct arrays which I insert when needed, but that's not the problem, I tried by simplifying the code with a basic search request but I didn't see any changes:
{
placeId: place_id,
fields: ['place_id', 'name', 'address_components']
}
// Or even more basic:
{
placeId: place_id,
fields: ['place_id,name,address_components']
}
Here is my actual code:
const basic_search_fields = [
'place_id',
'name',
'address_components'
]
const detailled_search_fields = [
'place_id',
'name',
'address_components',
'geometry',
'formatted_address',
'photo',
'url',
'formatted_phone_number',
'international_phone_number',
'opening_hours',
'website'
]
/**
* Construct a place search request
*/
createPlaceRequestFor: function (place, detailled = false) {
// Init the request with the fixed datas
let request = {
placeId: place.place_id,
}
// Set the fields for a basic or a detailled search
request.fields = detailled ? detailled_search_fields : basic_search_fields
return request
},
executePlaceRequest: function (request) {
return new Promise((resolve, reject) => {
this.PlacesService.getDetails(request, (results, status) => {
if (status == this.Google.places.PlacesServiceStatus.OK) {
resolve(results)
}
reject(status)
})
})
}