google-maps-services-go icon indicating copy to clipboard operation
google-maps-services-go copied to clipboard

Places: nearby search results do not contain opening hours info

Open timwangmusic opened this issue 5 years ago • 3 comments
trafficstars

Environment details

  1. Nearby search API
  2. MacOS Catalina 10.15.7
  3. SDK: googlemaps.github.io/maps v1.2.3

Steps to reproduce

  1. Make a basic nearby search request with fields specified in the code example below.
  2. Check maps.PlacesSearchResponse.Results.OpeningHours
  3. For some places the OpeningHours pointer is nil, and for others the WeekdayText and Periods slice 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?

timwangmusic avatar Nov 16 '20 08:11 timwangmusic

Hi, can some one take a look at the issue?

timwangmusic avatar Nov 26 '20 19:11 timwangmusic

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.

AlphaWong avatar Dec 13 '20 15:12 AlphaWong

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.

timwangmusic avatar Oct 30 '21 17:10 timwangmusic

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.

wangela avatar Nov 10 '22 18:11 wangela

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 avatar Nov 11 '22 03:11 timwangmusic

@timwangmusic sorry for missing your question. Yes, get the Place ID from the search results and use that Place ID to request Place Details.

wangela avatar Feb 09 '23 07:02 wangela