google-maps-services-go
google-maps-services-go copied to clipboard
Places: nearby search results do not contain opening hours info
Environment details
- Nearby search API
- MacOS Catalina 10.15.7
- SDK: googlemaps.github.io/maps v1.2.3
Steps to reproduce
- Make a basic nearby search request with fields specified in the code example below.
- Check
maps.PlacesSearchResponse.Results.OpeningHours - For some places the OpeningHours pointer is
nil, and for others theWeekdayTextandPeriodsslice lengths are zero
Code example
// basic request
mapsReq := maps.NearbySearchRequest{
Type: maps.PlaceType(placeType),
Location: &latLng,
Radius: radius,
PageToken: pageToken,
RankBy: maps.RankBy(rankBy),
Comment: are we supposed to always use DetailedSearch to get the OpeningHours info?
Hi, can some one take a look at the issue?
Hi, can some one take a look at the issue?
Can u offer a curl request for it? Then I can try it on my side.
Sorry for late response. I tried this call https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&rankby=prominence&type=restaurant&radius=5000&key=YOUR_API_KEY. I still can see that the opening_hours field only contains a Boolean value { open_now: true }
Maybe this is intended? The original issue was not about the REST API, but the maps Golang client. From the type OpeningHours struct it is not obvious at all that users should expect Periods []OpeningHoursPeriod field to be nil.
Our project recently updated to use the latest release 1.3.2 but still seeing this behavior.
opening_hours.weekday_text and opening_hours.periods are not available through Search, as documented at https://developers.google.com/maps/documentation/places/web-service/place-data-fields#places-api-fields-support.
The reference documentation for the returned PlaceOpeningHours object confirms what @timwangmusic is seeing, that what is left is open_now.
Thanks @wangela for the investigation. So I think for API users the procedure to get details around a location is first do nearby search and use place details API to get place details with place ID?
@timwangmusic sorry for missing your question. Yes, get the Place ID from the search results and use that Place ID to request Place Details.