我收到这样的错误:
{
"error_message" : "This API project is not authorized to use this API.",
"results" : [],
"status" : "REQUEST_DENIED"
}
Run Code Online (Sandbox Code Playgroud)
每当我运行这个: https://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&key=AIzaSyCKyVbBzwtgkyuut7P5mxK9vcOWMygCfp0
就我而言,我在地址链接中有#,input=City Clinical # 89所以我不得不将其删除
小智 5
您需要一个 API 密钥。否则它不会工作。
要获取 API 密钥,您必须访问此网页https://cloud.google.com/maps-platform/#get-started并选择您需要的产品。还要选择或创建一个项目,最后您必须设置一个计费帐户。不幸的是,据我所知,它不是免费的。
小智 5
发布值如下:
String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
// Destination of route
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
// Sensor enabled
String sensor = "sensor=true";
String mode = "mode=driving";
String key = "key="+getResources().getString(R.string.google_maps_key);
// Building the parameters to the web service
String parameters = str_origin + "&" + str_dest + "&" + sensor + "&" + mode + "&" + key;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters;
Run Code Online (Sandbox Code Playgroud)