The Places fields opening_hours.open_now
and utc_offset
are deprecated as of November 20, 2019, and will be turned off on February 20, 2021. These fields are deprecated ONLY in the Places Library, Maps JavaScript API. This guide shows you how to update your code to stop using these fields.
opening_hours.open_now
field
This section shows how to update this functionality for each type of Places request.
Place Details requests
The opening_hours.open_now
field is replaced by the opening_hours.isOpen()
method.
For Place Details requests, instead of requesting opening_hours.open_now
in the fields
request parameter, include opening_hours
and utc_offset_minutes
in the fields
request parameter, then call the opening_hours.isOpen()
method on the returned google.maps.places.PlaceResult
object to check whether the place is open. The following example shows a Place Details request that determines whether a place is open:
new google.maps.places.PlacesService(attrContainer).getDetails({ placeId: '...', fields: ['opening_hours','utc_offset_minutes'], }, function (place, status) { if (status !== 'OK') return; // something went wrong const isOpenAtTime = place.opening_hours.isOpen(new Date('December 17, 2020 03:24:00')); if (isOpenAtTime) { // We know it's open. } const isOpenNow = place.opening_hours.isOpen(); if (isOpenNow) { // We know it's open. } });
Find Place requests
For Find Place requests, there is no replacement for the opening_hours.open_now
field. We recommend making a Place Details request to get opening_hours
information.
Nearby Search & Text Search requests
For Nearby Search and Text Search requests, you can use the openNow
request parameter, which has the effect of filtering results to include only places that are currently open.
openNow:false
returns all places.openNow:true
returns only places that are currently open.
To list all places AND indicate openNow
status, first make a request using openNow:false
to get all places, then make a request using openNow:true
to get open places only. Then, merge the responses.
utc_offset
field
In Place Details requests, the utc_offset
field is replaced by the utc_offset_minutes
field. Simply replace occurrences of utc_offset
with utc_offset_minutes
in the fields
request parameter, and when reading this information from PlaceResult
.