Reputation: 19938
I'm currently using the Google Places API and have specified all place types in my query:
I was only able to get the first 40 results back with specifying all place types in my REST call - the maximum resulted search size is 60 places. According to this thread, we can only get the first 40 results if we specify all place types and the next_page_token
will not work beyond the first 40 item (beyond the 2nd page):
If that's the case, that would mean the places I'm searching for have to be predetermined / set or the user has to specify the places before they conduct a nearBy places search.
Some of the places that I'm searching for are pretty remote which means that there might not be "courthouses" there - it could just be forests in Africa everywhere. I want the user to be able to find the closest man-made place.
If I cannot search beyond 40 places, is that a way to find the more popular place types in an area? For example, when I switch on my phone, I want to be able to see there are these place types close by:
That way I can set the nearBy search to only these place types?
Upvotes: 0
Views: 903
Reputation: 2518
As pointed out on https://code.google.com/p/gmaps-api-issues/issues/detail?id=6998#c4, setting types
to include every type would be the same as omitting types
entirely — except it's not even doing that because you can only specify up to 20 types.
So just leave that parameter off, it's not helping you, or even doing what you think. (In fact by including every type
you get a very long URL, which might cause problems.)
Also, be aware that searching for more than one type at a time is deprecated. See http://googlegeodevelopers.blogspot.com.au/2016/02/changes-and-quality-improvements-in_16.html:
Beginning Feb 16, 2016, we are replacing the types restriction parameter with a new type search parameter. If you have been using the types parameter for Nearby Search, Text Search or Radar Search you will be affected.
Type search works similarly to types restriction, but it only supports one type per request.
Requests using the types parameter and those specifying multiple types (for example,
types=hospital|pharmacy|doctor
) will continue to return results until Feb 16, 2017, but we do not recommend using multiple types in a search request. After that date, requests with multiple types will no longer be supported. To ensure the best possible search results for your users, we recommend using a single type in search requests.
(Emphasis mine.)
So I think you should simply omit the types
parameter. E.g. https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-25.300968,29.124129&rankby=distance&key=YOUR_KEY
Upvotes: 0