我們正在使用Google Distance Matrix API來顯示用戶當前位置與目標點之間的旅行距離,以顯示Google地圖。我們正在使用以下url與使用應用程序包生成的Android密鑰和debug.keystore的sha1一起使用。如何使用Android密鑰從Android應用程序調用Google Distance api?
//路線起源 String str_origin =「origin =」+ origin.latitude +「,」+ origin.longitude;
// Destination of route
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
// Building the parameters to the web service
String parameters = str_origin + "&" + str_dest + "&" + sensor;
// String parameters = str_origin + "&" + str_dest + "&";
// Output format
String output = "json";
String url = "https://maps.googleapis.com/maps/api/distancematrix/" + output +"?"
+ parameters + "&mode=walking&key=" +"Android_Key";
但上面的網址給了以下效應初探,
{"destination_addresses" : [], "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address *.*.*.*, with empty referer", "origin_addresses" : [], "rows" : [], "status" : "REQUEST_DENIED"}
錯了我做的是什麼?。它的工作原理與沒有被映射到應用程序包名稱和SHA1 Android的關鍵。
謝謝你的幫助。但是發佈可以不使用API KEY。 – Tejaswini
您會收到錯誤消息,因爲有些東西缺少您的API控制檯再次檢查所有服務和使用您的服務 –