I am trying to use Golang version of Google Maps API (https://github.com/googlemaps/google-maps-services-go.git) to do NearbySearch. I have configured the requests with geolocation, type, radius and try to use the first page token returned from the first response, then include the token in the second request to get the results on second page. So on and so forth.
Is my understanding correct? When I tried the above method, the API returns "invalid request". Below is the code snippet.
token := ""
for i:=0; i < 3; i++{
req := &maps.NearbySearchRequest{
Location: &latlng,
Radius: 1000,
Type: "restaurant",
PageToken:token,
}
res, err := client.NearbySearch(context.Background(), req)
if err != nil{
log.Fatal(err)
}
fmt.Printf("Got %d results on this page
", len(res.Results))
fmt.Printf("Next page token is %s
", res.NextPageToken)
token = res.NextPageToken
}