Dmitry Nevzorov
Dmitry Nevzorov

Reputation: 615

Using Google Maps Directions API in android - what kind of API key is needed?

I'm embedding a map into my Android App and want to make it draw a route between two points. However, I have no clue, how to get a correct key for Directions Api - the server returns "error_message" : "The provided API key is invalid." as I'm trying to get the route via http request and using my android api key (a simple map and geolocation are working well with it). The request is (got from google docs examples): https://maps.googleapis.com/maps/api/directions/json?origin=place_id:ChIJ685WIFYViEgRHlHvBbiD5nE&destination=place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y&key=MyActualAndroidKey

So, the question is:

UPDATE

As API v. 3 do not prohibit using requests without key, the things work well without defining the key parameter in the query. But it works not for all requests, and the request above won't work. Apparently, query like http://maps.googleapis.com/maps/api/directions/json?origin=Chicago,IL&destination=Los%20Angeles,CA&sensor=false" works everywhere, including a browser. The difference between queries is in using place_id - it's possible to use it only with key.

Upvotes: 0

Views: 2372

Answers (2)

Deva
Deva

Reputation: 2536

yes. Obviously the key type should be server or none because you are using the web url (like https://maps.googleapis.com/maps/api/directions/json?) instead of mobile sdk.

Mobile(Key restriction type is either Android or iOS) API key will be required only when we use on mobile sdk to fetch and manipulate the google map feature.

Note: Key restriction type None will be supported for all platform but recommended is specific type of restriction based on platform.

Upvotes: 1

Mohd Mufiz
Mohd Mufiz

Reputation: 2236

I have integrated google direction api in one of my project and I have use server key for that.

go to https://console.developers.google.com enable google direction API create a server key user same key in the android to call direction API

Upvotes: 0

Related Questions