当我尝试在 android studio 中使用 java 获取路线时,我无法解决错误。
每当我运行我的代码时,它都会抛出类似
的错误 <块引用>"error_message" : "此 IP、站点或移动应用程序不是 授权使用此 API 密钥。从 IP 地址收到的请求 (IP 地址),带有空引用”,“路由”:[],“状态”: “REQUEST_DENIED”
我现在能做什么?任何人都知道请帮助并提前致谢。
private String getUrl(LatLng origin, LatLng dest, String directionMode) {
// Origin of route
String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
// Destination of route
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
// Mode
String mode = "mode=" + directionMode;
// Building the parameters to the web service
String parameters = str_origin + "&" + str_dest + "&" + mode;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters + "&key=" + getString(R.string.google_maps_key);
return url;
}