Google API密钥可以与Google Maps网络服务一起使用吗,例如地理编码?
我正在使用Google Maps Web服务执行服务器端(反向)地理编码.
I'm using Google Maps web services to perform server-side (reverse) geocoding.
我从Google API控制台获得了浏览器端和服务器端的Google API密钥,该密钥允许Google Maps JS API使用更高的请求配额,并允许按次计费(超额使用)(已在-通过JS浏览器).但是服务器端密钥似乎不适用于Web服务请求.
I've got a browser-side and server-side Google API key from the Google APIs Console, which permits the Google Maps JS API to use higher request quotas, and enables pay-per-use for overages (successfully tested in-browser via JS). But the server-side key doesn't seem to work on web services requests.
例如,此URL可以正常工作:
http://maps.googleapis.com /maps/api/geocode/json?sensor=true&latlng=43.477329,-80.548601
For example, this URL works fine:
http://maps.googleapis.com/maps/api/geocode/json?sensor=true&latlng=43.477329,-80.548601
但是,如果您添加"key = ...",参数,就像其他API一样,我的状态为REQUEST_DENIED.
But if you add a "key=..." parameter, as in the other APIs, I get a REQUEST_DENIED status.
我是在做错什么,还是Web服务API尚不支持此操作?将来会支持吗?
Am I doing something wrong, or is this just not supported on the web services APIs (yet)? Will it be supported in the future?
不,您没有做错任何事情.
Nope, you're not doing anything wrong.
很遗憾,我们对 Google Geocoding API (也称为服务器端地址解析"是Google的设计.如果您的应用每天需要超过2,500个服务器端地址,则需要升级到其 Google Maps API for Business 产品.
Unfortunately, enforcing tight limits on the Google Geocoding API, also called "Server-Side Geocoding", is Google's design. If your app needs more than 2,500 Server-Side Geocodes per day, then you'll need to upgrade to their Google Maps API for Business product.
坚持下去,情况变得更糟.
Hold on, it gets worse.
如果您的应用程序的服务器IP地址与其他应用程序共享,则该2500个请求的每日限制适用于所有其他应用程序.其中包括与您共享相同服务器IP地址但不属于您的应用程序!对于任何PaaS(例如Google App Engine或Heroku),这都是常见的情况.因此,即使您的应用程序今天完美运行,也无法保证它明天仍能正常工作.
If your app's server IP address is shared with other apps, that 2,500 request daily limit applies to ALL of them. This includes apps that share the same server IP address as you, but don't belong to you! This can be a common situation with any PaaS, like Google App Engine or Heroku. So, even if your app works flawlessly today, there is no guarantee that it's still going to work tomorrow.
在地理编码策略" 的文章中,Google指出解决方案是几乎总是"通过地理编码服务使用客户端地理编码" Google Maps JavaScript API V3 .主要原因是对每个用户,每个会话强制实施限制.除非您要在客户端上执行地址解析批处理(这不是典型的用例),否则这样的请求不应超出配额限制.
In the article, "Geocoding Strategies", Google indicates the solution is to "almost always" use "Client-Side Geocoding" via the Geocoding Service, part of the Google Maps JavaScript API V3. The primary reason is that limits are enforced per user, per session. Requests like this shouldn't run up against quota limits unless you're executing geocode batches on the client (not a typical use case).
地理编码策略"文章中的一个金块:设计一个页面,接收用户输入,调用客户端Geocode
服务方法,然后将该信息传递到服务器应用程序中,在此可以对其进行处理,并希望将其缓存.这是理想的FAR,但是如果无法升级到Google Maps API for Business,则可能是唯一的方法.
One golden nugget from the "Geocoding Strategies" article: Design a page that takes user input, calls the client-side Geocode
service method, then passes that information to your server app where it can be processed, and hopefully cached. This is FAR from ideal, but if upgrading to Google Maps API for Business isn't an option, it might be the only way to go.
祝你好运!