2014-03-14 68 views
1

我正在使用谷歌地圖v2的android。我想調用api來獲取android設備的分數。我註冊了Google控制檯密鑰,我可以在android上查看地圖。我用這個鍵在方向API調用像這樣包括:谷歌地圖從Android設備調用方向api的錯誤

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false&key=API_KEY 

的API_KEY是我的地圖創建的關鍵:

api key for maps and directions

但是,當我從Android應用程序請求調用方向api,我得到這個返回:

{ 
    "error_message" : "This IP, site or mobile application is not authorized to use this API key.", 
    "routes" : [], 
    "status" : "REQUEST_DENIED" 
} 

我該如何解決這個錯誤?請幫助

謝謝

回答

6

這是調用以獲得兩個地理點之間的方向路徑的URL。

http://maps.googleapis.com/maps/api/directions/json?origin=23%C2%B0%201%27%2050.49711640%22%2C%2072%C2%B0%2034%27%2014.520786762%22&destination=22%C2%B0%2017%27%208.23132830%22%2C%2073%C2%B0%2012%27%2026.766651630%22&sensor=true&mode=driving 

沒有必要通過方向URL KEY=api-key ..

的話,請刪除此paramter.and通話網址按上面.. API密鑰只放在<meta-data>標籤清單文件。

請撥打此網址:

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false 

我希望它的對你有用。

+0

這是正確的。非常感謝你的回答。這非常有用。 – user1597721

+0

從通話中刪除API密鑰是關鍵。謝謝。 –

+0

這不會有一個使用限制嗎? – Mauker