When I executed this request for 5000m radius, I could obtain 60 records, when using next_page_token for subsequent requests.
https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=&key=
But when I executed request with radius=50000, I could obtain only 38 records.
This is a nature of the Places API web service. It doesn't work as a database search and doesn't return all possible results. It returns only most prominent results for specified area. How Google decides which result is prominent and which is not we don't know, they typically don't share their internal algorithms.
Related
I have a location and I am placing a call to nearbySearch() of the Places library through Google Maps Javascript API to get restaurants within 1000 meters of my location. I then loop through the first 20 restaurants and make a call to getDetails() so that I can pull out the website of each restaurant. This works fine until I get to about the 10th restaurant, then I start to get QUERY_OVER_LIMIT status sent back from the getDetails call.
I have slowed down my calls to once every 300ms, but I still get the QUERY_OVER_LIMIT error. Based on what I've read, a call to the Places library every 300ms should be well within the limit. When I read documentation, it states that the per second limit for the Places API (which supposedly also applies to the Places Library of the Maps Javascript API) is 100 requests per second. When I log into my API dashboard, it tells me my per minute limit for the Places API is 6000 per minute. At one request every 300ms I am nowhere near my limits, so I'm at a loss to understand why I keep getting this error. Naturally I could slow it down much more, but this degrades the user experience and since the rate seems unpredictable, it's hard to settle on a rate that I know will produce consistent results.
Places API Requests per Second
Places API Request per Minute
Places Library [what you are using when you make getDetails() requests in Javascript] and Places API [the product your screenshots are talking about] are two different things with two different quotas.
When you use Places Library, Google rate limits you which is what you are seeing.
https://developers.google.com/maps/documentation/javascript/places#UsageLimits
To be able to make more batch requests like you want, use Places API to get the Details for all of the places (which will get pricey pretty quick).
https://developers.google.com/maps/documentation/places/web-service/details
https://developers.google.com/maps/billing/gmp-billing#places-details
Google references this:
https://developers.google.com/maps/documentation/javascript/geocoding
And states:
The per-session rate limit prevents the use of client-side services for batch requests, such as batch geocoding. For batch requests, use the Geocoding API web service.
However, when you go to the Geocoding API web services page, I see no reference to batch processing. The above sentence infers that you can do batch processing. I need to send a large number of addresses to get lat and longitude, but doing individual calls for each address is taking extremely long periods of time and need a more efficient method. Hopefully, a single batch call to send all the addresses.
Any ideas of how to batch process addresses on google to get lat and longitude?
I have seen this Google Batch Geocoding API
However, it states you can not which is not what the above google statement infers.
Per the Geocoding API web service documentation:
Other Usage Limits
While you are no longer limited to a maximum number of requests per day (QPD), the following usage limits are still in place for the Geocoding API:
50 requests per second (QPS), calculated as the sum of client-side and server-side queries.
You are just limited to 50 requests per second and have to pay for them (after you use up the $200 credit)
The best way I found to solve this problem is to use the Directions API with up to 27 destinations (origin, destination and 25 waypoints) and get your geolocation for the response legs. The position accuracy is slightly lower than in the geocode case from what I observed, but it is still a great tradeoff.
In the worst case you will have to call the Directions API twice when one or more addresses are not found in your call. The good thing in this case is that the Directions API will give you a response with the geocoded_waypoints which will specify the NOT_FOUND locations with a geocoder_status. After that, you can eliminate the bad ones and call again.
There are currently no available feature for a Geocoding API to handle multiple address at a single call, however, you may implement the batch process via cURL, by doing this, you can call multiple requests at once automatically. Implementation will be up to your use case as well.
If I check the coordinates for a location by making a request to the Geocode API like this https://maps.googleapis.com/maps/api/geocode/json?address=Los%20Angeles,%20CA,%20United%20States&key=your-browser-key
Then it returns 34.0522342,-118.2436849 for LA, if I then go the reverse geocode API and enter those coordinates then it shows no results?
How's that possible? API a returned a set of data that's not recognized by API b? Shouldn't they both use the same data?
Is this some kind of bug, or am I doing something wrong somewhere?
I've just gotten the following message from Google
Dear Maps APIs Premium Plan customers,
Reverse geocoding results in the Geocoding API will soon be updated to provide better quality worldwide. While the new results will often be different from the current results and contain different Place IDs, they should not require adjustments in client applications.
The new results are currently rolled out to non-Premium-Plan users. We plan to make the new results the default for Premium Plan customers on September 17th 2018.
Applications can preview the new results ahead of September 17th by adding the new_reverse_geocoder=true parameter to their Geocoding API requests. Please note that adding this parameter to requests without the latlng parameter will result in an error response (INVALID_REQUEST).
The new results can also be visualized by clicking on the base map (or entering a latlng) in the Geocoder Tool at https://google-developers.appspot.com/maps/documentation/utils/geocoder/
The new results provide the following improvements:
Increased ratio of rooftop results in favor of interpolated addresses.
Decreased ratio of requests receiving only political results like a city or a neighborhood (ie, incomplete addresses).
Decreased distance from input latlng coordinates to the nearest result.
In areas with sparse coverage, establishments are returned in addition to geocodes.
Decreased ratio of requests receiving results more than 400 meters from the input latlng.
Please let us know if you find issues with the new results. Quality issues are best reported in the Maps API public issue tracker at https://issuetracker.google.com.
So, as you can see Google is launching a new version of reverse geocoder. I've tried your request with old version adding the &new_reverse_geocoder=false parameter and got results
https://maps.googleapis.com/maps/api/geocode/json?latlng=34.0522342%2C-118.2436849&new_reverse_geocoder=false&key=MY_API_KEY
At this point it looks like regression in new version of reverse geocoder.
Update
Google tracks this issue in the bug:
https://issuetracker.google.com/issues/115484101
I'm using the google maps distance matrix javascript API to query the travel time from one point to about 50 destinations.
in order to do this, I need to break my query up into multiple chunks, since the google maps API allows only a maximum of 25 destinations per request.
the problem that I'm having is the synchronization of the request and the result.
other APIs offer the option to include a key that lets the developer match a request and an asynchronous result.
however, since such a parameter is missing from the request specification, I have no idea how to make sure that I'm matching the right data to my incoming results.
I would be glad for a "clean" workaround - currently the only idea that I'm having is to have a unique number of destinations for each request, for instance the first with 25, the next with 24 destinations and so on. but I would not consider this a satisfactory approach.
thank you
I have a number of target points on the map and a source location. I need to find the target point closest to the source location. The trick here is that "closest" means the shortest route. I can't use a simple crow fly distance.
This is essentially a one-to-many routing problem. I can get the answer by running a routing API call for each pair of points but that would be too slow and will blow up API usage.
Is there a way to do it with a single request using Google Maps API (I am ok paying for it if necessary)?
If yes, then what are the limits to the number of points, the request frequency, etc?
If no, is there another service that can do it?
Say I have a lot of points (thousands). Is there a way to upload them somehow and only use the source location in my requests?
You should take a look to Distance Matrix Service
You can specify a starting point and an end point (even intermediate waypoints), then get the distance in kilometers / miles by route.
To answer your questions :
Is there a way to do it with a single request using Google Maps API (I am ok paying for it if necessary)
Yes you can, just use the service given below
If yes, then what are the limits to the number of points, the request frequency, etc?
To quote the Usage limits and requirements :
The following usage limits are in place for the Distance Matrix service:
Maximum of 25 origins or 25 destinations per request; and
At most 100 elements (origins times destinations) per request.
Requests are also rate limited. If too many elements are requested within a certain time period, an OVER_QUERY_LIMIT response code will be returned.
Say I have a lot of points (thousands). Is there a way to upload them somehow and only use the source location in my requests?
I'm not sure what you really want, but you can define a point as "source location", then load it (from SQL, KML etc...), then load the targets and call the service to find which one is the closest.