简体   繁体   English

Google Maps REST API - 使用AJAX请求限制请求

[英]Google Maps REST API - request limit with AJAX request

I am trying to determine how the daily Google Maps REST API request limit applies in the case of JavaScript run from the client machine requesting information via AJAX. 我正在尝试确定在从客户端计算机通过AJAX请求信息的JavaScript运行情况下,每日Google Maps REST API请求限制的适用情况。

For example, if I make a Geocode request in a php script to one of the REST APIs with 例如,如果我在php脚本中向其中一个REST API发出Geocode请求

$response = simplexml_load_file($rest_request_url);

I'd expect Google to know the servers IP and subtract 1 from the total allowed for that day. 我希望Google知道服务器IP并从当天允许的总数中减去1。 However, if I were do the same from JavaScript with an AJAX GET request, how would Google know it was the server that hosted that JavaScript if it was run from the client machine and log the server IP rather than the clients IP? 但是,如果我在JavaScript中使用AJAX GET请求做同样的事情,谷歌如果知道它是托管该JavaScript的服务器,如果它是从客户端计算机运行并记录服务器IP而不是客户端IP?

This may fall more generally under the bracket of how JavaScript executes generally, however the above illustrates the point well. 这可能更普遍地落在JavaScript如何执行的范围内,但是上面说明了这一点。

Google elucidates this situation in their Geocoding documentation here: https://developers.google.com/maps/articles/geocodestrat#client . Google在其地理编码文档中阐述了这种情况: https//developers.google.com/maps/articles/geocodestrat#client This isn't Maps, but the info there is analogous. 这不是地图,但信息类似。 Of note: 值得注意的是

As geocoding limits are per user session, that limit counts against the consumer of your application. 由于地理编码限制是每个用户会话,因此该限制将针对您的应用程序的使用者

Emphasis mine. 强调我的。 Google doesn't care about the server is hosting the HTML file in which the map happens to be embedded. Google并不关心服务器是否托管了嵌入地图的HTML文件。 As far Google is concerned, no requests are coming from your server at all. 就Google而言,根本没有来自您的服务器的请求。 The requests originate solely from the client visiting your web site. 请求仅来自访问您网站的客户。

As a practical matter, the request limits are there to prevent people from carpet-bombing the Maps API with the intent to mine and/or cache the data, and to force really heavy users to pay for a subscription. 实际上,请求限制是为了防止人们对Maps API进行地毯式轰炸,意图挖掘和/或缓存数据,并迫使真正沉重的用户支付订阅费用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM