Storing Vs Calling Google Places API - google-maps

My application queries Google Geocoding API once per user.
It stores their lat lon for analysis later.
I am considering a feature which calls Google Places API, and shows the user some "Places"
near them, on a map.
I do not want to store nearby Google Places. There is considerable overhead in this process.
Many people, on message boards, stress the importance of not bombarding the Places API from within my application. However, Google Places API allows a huge volume of daily traffic, much higher than Maps API and much higher than my website will use.
Can anyone definitively settle this?

The only possible reason to stress reducing the number of calls to the Places API is if you may be in danger of exceeding the stated quota limitsdev-guide (currently set at 100,000 for licensed sites). If you are confident that you will not approach or exceed the limit, then your assessment is correct. The added overhead associated with attempting to store results as a way to avoid similar Places API requests is not worth the added complexity. Simply call the Places API, process the results, and then place them on your Google Map to display to your user(s).

Related

Google API Future Prediction of Traffic = Typical Traffic shown on Google Maps (maps.google.com)

I just wanted to ask if the future traffic information given in the Google API (Google Distance Matrix API to be exact) is the same as the traffic data used in the typical traffic overlay in the Google maps app. Aren't they both based on historical data, and thus, should be similar if not the same?
Thank you and I will appreciate your help!
Yes, so long as you don't specific traffic_model other than best_guess.
They both use historical traffic data to predict "likely" traffic conditions in the near future, based on time of day and day of week. However, your API requests may not always carry the exact same meaning as your input on Google Maps, so there may be cases where each return slightly different results. Should you find big differences, please file a bug.

Terms and Conditions Google Maps: Can I store lat/lng and address components?

This question has been asked in a few places on SO, but I've found the answers to be either slightly contradictory or "thin"... so I'm not sure if asking again will help but here goes.
The google "help" page says that the google team maintains a "presence" on SO, so if you are a google chap, please could you make this clear, and if you are not please also make this clear, thank you :)
So, what I want to do...
User searches for a set of locations. These will be used to form a travel itinerary. I want to take the lat/lng and the address components and store them in my own database so that when another uses search for trips in some country, some place etc etc I can go about finding them.
The big question, does the terms of conditions allow this? The relevant bit that worries me is...
10.1.3 Restrictions against Data Export or Copying.
... snip ...
(b) No Pre-Fetching, Caching, or Storage of Content. You must not
pre-fetch, cache, or store any Content, except that you may store: (i)
limited amounts of Content for the purpose of improving the
performance of your Maps API Implementation if you do so temporarily
(and in no event for more than 30 calendar days), ...snip... For example,
you must not use the Content to create an independent database of "places"
or other local listings information.
Would what I want to do violate this. It sounds to me like it might, but then that renders the question, why would I use google maps for this kind of application? Other travel sites appear to?!
There is no problem if you store
latitude and longitude
addresses
As those would be "user preferences" in your app.
The restrictions on data export refer to the tiles and photos used to display the maps. In general people want this feature to have a cache mechanism or provide offline functionality. This is not allowed* and only the official mobile app has this features.
*Google actually allows it, but you have to read the finer print, more on that below.
Longer answer, analyzing the ToC:
No Pre-Fetching, Caching, or Storage of Content. You must not pre-fetch, cache, or store any Content...
What does content mean? This is map tiles, terrain tiles, photos of places, satellite photos etc. The content, in the ToC, is anything that has been created by Google and provided as part of the Google map service. But, not everything provided in the service has been created nor is owned by Google.
Addresses are not created or owned by Google, this is public information. What Google has done is to gather them and put them in a presentable, easy to search, interface. But it is not part of "the content".
GPS locations are not created or owned by Google, this is public information as well. In fact, GPS was created by the department of defense (DoD) in the US. They are the ones who control its use.
...For example, you must not use the Content to create an independent database of "places" or other local listings information.
It wouldn't be fair to Google if you downloaded a subset of the content, lets say all the tiles and photos for your home town. Once you have your copy of the files, you do a little processing on them, maybe add trivia or fun facts that only you know because you grew up there. And then use that to provide a re-branded service. Something called JimboMaps perhaps. That is the type of thing that is prohibited.
you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation if you do so temporarily
Guess what, you are actually allowed to store content in you database. Any of it, photos, tiles etc. The catch is:
You can store limited amounts. A few blocks, probably a small region is ok. But don't store a whole town or suburb.
You can't store anything for more than 30 days.
The only valid reason to do this is performance improvement of your application. See this: Google Maps v3 - Map tile caching on client?
...you must not use the Content to create an independent database of "places" or other local listings information.
It is just saying that you are not allowed to create JimboMaps.
The newest Google Maps Platform Terms of Service (which takes effect July 16, 2018) is a bit more explicit about this.
3.2.4 Restrictions Against Misusing the Services.
(a) No Scraping. Customer will not extract, export, or scrape Google
Maps Content for use outside the Services. For example, Customer will
not:(i) pre-fetch, cache, index, or store Google Maps Content for more
than 30 days; (ii) bulk download geocodes; or (iii) copy business
names, addresses, or user reviews.
Yes, the address might be public knowledge, but the process to obtain it is subject to the terms of the service you use...
This is from Google's Developer pages:
https://developers.google.com/maps/articles/geocodestrat
*Caching Considerations
The Google Maps API allows you to cache geocodes (i.e. store them on your server for a limited period). Caching can be useful if you have to repeatedly look up the same address. However, there are two important things to keep in mind.
1.The Google Maps API Terms of Service allow you to use geocodes derived from the service on Google Maps or Google Earth only. You may not sell or distribute them in other fashion.
2.Geocoding changes often as our data gets more and more accurate. So even if you have cached data, you should refresh it periodically, to make sure you are getting the best geocodes for your locations.
The Google Maps API for Flash requires the use of API keys. Many people mistakenly think quotas are tied to keys. However, keys don't affect your geocoding quota at all. Registering for a new key won't help. Quota is solely tied to IP addresses. Therefore a new key won't give you any more quota at a particular IP address.*
This quote from their website (https://developers.google.com/maps/documentation/geocoding/geocoding-strategies) says you can save data for your use if you know you will need it many times, but recommends you update periodically.
Caching considerations
The Google Maps Platform Terms of Service allow you to cache geocodes (that is, store them on your server for a limited period). Caching can be useful if you have to repeatedly look up the same address. However, keep in mind that geocoding results change as our data gets more and more accurate. So even if you have cached data, you should refresh it periodically, to make sure you are getting the best geocodes for your locations.
TL;DR: I think storing lat/long from services provided by Google is not allowed
Google Maps Platforms terms (21.11.2019)
3.2.4 Restrictions Against Misusing the Services.
(a) No Scraping. Customer will not extract, export, or otherwise scrape Google Maps Content for use outside the Services. For example, Customer will not: (i) pre-fetch, index, store, reshare, or rehost Google Maps Content outside the services; (ii) bulk download Google Maps tiles, Street View images, geocodes, directions, distance matrix results, roads information, places information, elevation values, and time zone details; (iii) copy and save business names, addresses, or user reviews; or (iv) use Google Maps Content with text-to-speech services.
To me it looks like storing lat/long is (even explicitly) prohibited.
"Google Maps Content" is actually defined in the terms & conditions.
"Google Maps Content" means any content provided through the Services (whether created by Google or its third-party licensors), including map and terrain data, imagery, traffic data, and places data (including business listings).
Also the remark about it being ok to cache data for some time and periodically refresh it is no longer there, see Geocoding API Policies.
Pre-Fetching, Caching, or Storage of Content
Applications using the Geocoding API are bound by the Google Maps Platform Terms of Service. Section 3.2.4(a) and (b) of the terms states that you must not pre-fetch, index, store, or cache any Content except under the limited conditions stated in the terms.
Note that the place ID, used to uniquely identify a place, is exempt from the caching restriction. You can therefore store place ID values indefinitely. Place ID values are returned in the place_id field in Geocoding API responses.
For what it's worth you can store Place IDs instead of lat/long ;-)
You may want to use another service for lat/long geocoding.
Like others have said, the updated terms https://cloud.google.com/maps-platform/terms/#3.-license. section 3.2.3 (b) explicitly states (May 6, 2020)
(b) No Caching. Customer will not cache Google Maps Content except as expressly permitted under the Maps Service Specific Terms.
BUT
The specific terms (handily not linked in the terms, that I could easily see) mention this
(hopefully this is the specific terms https://cloud.google.com/maps-platform/terms/maps-service-terms updated June 14, 2020)
1.4 Caching. Customer can temporarily cache latitude (lat) and longitude (lng) values from the Directions API for up to 30 consecutive calendar days, after which Customer must delete the cached latitude and longitude values. Customer can cache Directions API Place ID (place_id) values, in accordance with the Directions API Policies.
Section 1.4 is for the directions API, but most of the other API's have the same exception. Unfortunately it doesn't mention address data.

Google Javascript API Geocoding Limits

What are the limits for client side geocoding with Google Maps JavaScript API v3?
My research:
Google Maps PHP API has a limit of 2500 geocode requests per day (https://developers.google.com/maps/documentation/geocoding/#Limits)
Google Maps Javascript API v3 has a limit of 25000 map loads per day (https://developers.google.com/maps/documentation/javascript/usage)
Google suggests using javascript API for geoocoding to avoid the 2500 limit through the PHP API. It states "running client-side geocoding, you generally don't have to worry about your quota" (https://developers.google.com/maps/articles/geocodestrat#client)
However, nowhere does it state in any of the documentation what the geocoding limits are through the Google Maps JavaScript API v.3.
(This has been bothering me for a while, and I have researched it on more than one occasion and failed to find a solid answer)
I work in Maps for Business support at Google. The following is my personal opinion, not Google's, but let's just say I'm rather familiar with this topic!
First, it's important to distinguish between client-side geocoding (JavaScript calls to google.maps.Geocoder) and server-side geocoding (HTTP requests to /maps/api/geocode). This question and answer are specifically about client-side geocoding; for server-side limits, see here. In particular, the oft-mentioned 2,500 requests per IP per day limit applies only to server-side geocoding, not client-side.
So the short answer is, there is no documented query limit specifically for client-side geocoding. Once a client has loaded the Google Maps JavaScript API library, it can make as many geocode requests as it likes, provided they're done at a sane speed. Two rules of thumb to ensure you don't run into problems:
Initiate geocoding in response to user interaction, and you'll be fine even if there are short request bursts (eg. click a button to geocode several addresses).
Catch any OVER_QUERY_LIMIT errors and handle them gracefully (eg. exponential backoff). Here is some sample code in Python.
But please do not try to busy-loop the geocoder or hammer away at it for hours on end, there are protections against abuse.
UPDATE
As of 2017 the client side quota is calculated against corresponding web service quota. Please have a look at Christophe Roussy's answer.
Always read the latest you can find on an official Google website for the proper API version, a dated stackoverflow answer is not an up-to-date reference !!!
https://developers.google.com/maps/documentation/geocoding/usage-limits
Here is what it said when I wrote this answer:
Google Maps Geocoding API Usage Limits
2,500 free requests per day, calculated as the sum of client-side and
server-side queries.
50 requests per second, calculated as the sum of client-side and
server-side queries.
Enable pay-as-you-go billing to unlock higher quotas:
$0.50 USD / 1000 additional requests, up to 100,000 daily.
In general I think Google is happy as long as the queries come from real human users as this is of some value to them.
There are also ways to save a few requests by caching results for up to 30 days:
https://developers.google.com/maps/premium/optimize-web-services#optimize
Based on https://developers.google.com/maps/articles/geocodestrat,
Client-side geocoding through the browser is rate limited per map
session, so the geocoding is distributed across all your users and
scales with your userbase.
So, what is rate limits per map session?
As geocoding limits are per user session, there is no risk that your
application will reach a global limit as your userbase grows.
Client-side geocoding will not face a quota limit unless you perform a
batch of geocoding requests within a user session. Therefore, running
client-side geocoding, you generally don't have to worry about your
quota.
Ok, what is the limit? Here we go
https://developers.google.com/maps/documentation/business/articles/usage_limits
With a rate limit or 10 QPS (queries per second), on sending the 11th
request your application should check the timestamp of the first
request and wait until 1 second has passed. The same should be applied
to daily limits.
Still not clear? me too.
This is the closet answer that I found from their document and it says "rate limit of 10 requests per second"
https://developers.google.com/maps/documentation/business/webservices/quota
I don't think a user session can send 10 requests per second, thus I consider it as limitless.
I asked this recently about the Places library (or rather, researched it and came to a conclusion):
Regarding Places Library for Google Maps API Quota limits
Basically, it seems that Map loads with key are limited to 25,000 per day per domain (that might not be right, but i'm pretty sure thats the case).
Geocoding limits are limited in the following way:
2,500 if you're using an API key without setting up billing
100,000 if you're using an API key and have set up billing
If you're doing server-side geocoding (pre-caching results or similar), then your geocoding is per domain, and you're going to run out of requests pretty quickly. (i.e. in a similar vein to if you're doing places requests using the REST API like so: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=XXXX)
If you're using the javascript library, using the autocomplete functionality or PlacesService like so:
service = new google.maps.Geocoder();
then the limit (2,500 or 100,000 respectively), is per end-user, so your limit scales with your user base.
According to the article you linked (under When to Use Server-Side Geocoding):
The 2,500 request limit is per IP address.
So - what exactly do you mean by limit? Limit for the hosting application, or for a client running it?
The statement above tells me that there is no limit for the "host"; without a key or enforceable referrer URLs, there is no (good) way for Google to determine from whence a geocoding request originates. That's kind of the beauty of REST, among other things.
It also tells me that even if they could enforce it, they haven't set a limit. This would likely be counter-productive to their business model.

Geocoding API exceeds rate limit

I am using the Geocoding API for querying the location coordinates for a set of 100K users. However, because of rate limit, I am unable to fire more than 2500 requests per day. I need unrestricted access for the purpose of my study. This is for a project in my university. Can someone guide me in the right direction?
Per the Usage Limits section of the terms of service, even commercial users of the Google Geocoding API do not have unrestricted use:
Users of the standard API [are allowed] 2,500 free requests per day, calculated as the sum of client-side and server-side queries. ... Premium Plan customers: [receive a] shared daily free quota of 100,000 requests per 24 hours; additional requests applied against the annual purchase of Maps APIs Credits.
50* server-side requests per second. ... These limits are enforced to prevent abuse and/or repurposing of the Google Maps Geocoding API, and may be changed in the future without notice. Additionally, we enforce a request rate limit to prevent abuse of the service. If you exceed the per-day limit or otherwise abuse the service, the Google Maps Geocoding API may stop working for you temporarily. If you continue to exceed this limit, your access to the Google Maps Geocoding API may be blocked.
You may want to review the Geocoding Strategies documentation from Google and/or rethink your implementation approach. Does the geocoding need to be dynamic, or is it from a preexisting set of data? Are you obligated to use the Google Maps Geocoding API, or could you use another service?
It's worth noting that most geocoding services will have a similar limit, and if they don't, hitting them with a run of 100,000 or more requests is generally recognized as being poor practice unless a prior arrangement has been made. You may want to consider using another geocoder service, or hosting your own geocoder (e.g. TwoFishes), to get around these limits.

Google maps api v3, query limit exceeded more then 72 hours ago

I need to know how to reset the query limit for the Google Maps API v3. I know that I exceeded it more than three days ago, but it has not reset and I am still hitting it if I send more then 5 requests. How do I restore it completely to be able to get that 2500 (or whatever the request limit is) again?
I need to geocode some addresses and put them (lat, lon) into a database. I have done so far 2500 addresses. I need to do another 1000 and then it will be just one request on page load.
According to the Google Geocoding API documentation, there are actually two limits. First of all, there is the 2,500 request per day limit, which you say you triggered a few days ago. However, there is also a separate rate limit, which is probably what you are hitting here.
The rate limit will prevent you from making many successive geocoding requests in a short time, which it seems is what you're trying to do. There is no way around this, since making 1,000 requests on a single pageload is not the intended use of the Google Geocoding API.
Additional, according to Google:
Note: the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.
This probably means that your overall plan to use the Google geocoder and store the results in a database is a violation of Google's terms of service.
If (and only if) you are going to show the results & marker on a Google Map (required by ToS), then these articles would probably help you:
Geocoding Strategies to make the right decision as to whether you need to use PHP (server-side) or JavaScript (client-side). It sounds like you're right to use PHP.
Geocoding Addresses with PHP/MySQL to do the batch geocoding, provided your use case complies with the Terms of Use ;) -- mind the paragraph about Timing the Geocode Requests as Rohan points out your issue is likely that you're sending requests too fast.