Reputation: 513
I got a poly line between two locations using google maps and when i want to get routes and directions between those two locations by using this URL using Json parsing https://maps.googleapis.com/maps/api/directions/json?origin=fromlocation&destination=destinationlocation&sensor=false&key=********API KEY********* it is getting the json parsing as { "error_message" : "This IP, site or mobile application is not authorized to use this API key.", "routes" : [], "status" : "REQUEST_DENIED" } I have got the authorized APIKEY using keytool and with package name and finger print key
here is the code what i have done thanks in advance and sorry for my english...
private class GetContacts extends AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(DirectionActivity2.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
String URL="https://maps.googleapis.com/maps/api/directions/json?origin=start&destination=end&sensor=false&key=****API KEY*****";
ServiceHandler sh = new ServiceHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(URL, ServiceHandler.GET);
Log.d("Response: ", "> " + jsonStr);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
}
}
Upvotes: 2
Views: 3950
Reputation: 10338
Update June 28 2019:
Previously, google used to allow calling directions, geo-location api's without an api key up to a certain extent. It was a handy feature for development as you could just change the url in the browser. They have updated their policy.
Now you will need to provide a valid api key. More information in following link.
Previous Answer:
Try removing the API key. I used this and it is returning me a valid json.
Upvotes: 4