2013-08-23 70 views
8

我們使用Google Geocoding API將地址映射到經度和緯度。哪裏可以放置Google Geocoding API的API密鑰?

這裏是編碼樣本URL(返回JSON) -

http://maps.googleapis.com/maps/api/geocode/json?address=Dallas&sensor=false

消息:OVER_QUERY_LIMIT

好吧,這是有道理的,因爲我們超過了2500漲停,所以我們把API關鍵是這樣 -

http://maps.googleapis.com/maps/api/geocode/json?key=xxxxx&address=Dallas&sensor=false

消息:REQUEST_DENIED

我想知道在哪裏/如何放置API密鑰。

+0

只是爲了確認,你有一個商業帳戶的API密鑰 - 一般使用谷歌地圖api不是免費的密鑰? – Matthew

+0

從這裏添加信息到我的回答:https://developers.google.com/maps/documentation/business/clientside/ – Matthew

+0

只需闡明這一點,開發人員控制檯(API)密鑰只能與Google地圖客戶端一起使用,側邊的API。您要撥打的電話是Google地圖地理編碼網絡服務API,因此是「REQUEST_DENIED」響應。 –

回答

11

貌似在3版本,你需要通過在URL中ClientID,而不是一個key如您在免費版本做:https://developers.google.com/maps/articles/v2tov3#newkey

所以您的網址應該是這樣的:http://maps.googleapis.com/maps/api/geocode/json?client=xxxxx&address=Dallas&sensor=false

不幸運地有一個付費帳戶,所以我不能測試 - 但我認爲這會讓你走上正確的道路。

從這個鏈接有關:https://developers.google.com/maps/documentation/business/webservices/

Client ID

You must include your client ID in all API requests. Your client ID identifies you as a Maps API for Business customer and enables support and purchased quota for your application. Requests made without a client ID are not eligible for Maps API for Business benefits.

If you're switching from the free API services to a Maps API for Business implementation, you must remove the key parameter from your requests. Google Maps API web services will deny requests made with both a client ID and a key.

More information is available in the Authentication and Authorization chapter of this guide.

If you have lost your client ID, you can recover it by logging in to the support portal and clicking Maps: Add URLs from the links on the left of the page.

編輯

有關詳細信息,包括通過你的客戶端ID地球API,V2 API指令,以及地圖API爲Flash,請閱讀Loading Client-side APIs

如果您丟失了客戶端ID或加密密鑰,可以通過登錄到support portal並單擊頁面左側鏈接中的地圖:添加URL來恢復它們。

+2

我們剛剛在電話上與Google聊天。不幸的是,我們沒有Geocoding商業帳戶,每年花費**** 17,000美元。現在我們正在和我們的客戶交談。非常感謝你的幫助。 – Win

+0

爲了避免在應用程序的數據庫中出現緩存結果的限制 - 取決於您的地理編碼(地址常常相同 - 這基本上意味着您需要掏空,或常用地點經常重用,這意味着您只需要爲新的API調用谷歌的API)。 – Matthew

+0

相關:http://gis.stackexchange.com/questions/15052/how-to-avoid-google-map-geocode-limit – Matthew