googlemaps / google-maps-services-go

Go client library for Google Maps API Web Services
https://pkg.go.dev/googlemaps.github.io/maps
Apache License 2.0
737 stars 214 forks source link

Places: nearby search results do not contain opening hours info #249

Closed timwangmusic closed 1 year ago

timwangmusic commented 3 years ago

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 commented 3 years ago

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

AlphaWong commented 3 years ago

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.

timwangmusic commented 2 years ago

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.

wangela commented 1 year ago

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.

timwangmusic commented 1 year ago

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?

wangela commented 1 year ago

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