Google Directions API failing to return results in

2019-05-12 01:00发布

I’m trying to use Google Directions API. I have the SDK all set up. I have enabled Google Maps SDK for iOS under the Services in the developer console. Below is the URL I've built to get the directions.

There are two types of keys in the developer console.

enter image description here

First I tried with the Key for iOS apps.

https://maps.googleapis.com/maps/api/directions/json?origin=-37.814107,144.96328&destination=-31.953004,115.857469&key=<Key for iOS apps>

But I got the error This IP, site or mobile application is not authorized to use this API key.

When I searched for a solution to this error I saw in a few StackOverflow answers (1, 2) that iOS keys are not supported. In the answers they're talking about the Google Places API but I thought it might be the same case with Directions because the error was the same.

So I replaces the Key for iOS apps with Key for browser apps and ran it again but I got a new error This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console.

My question is are there any other APIs I have to activate in the Services to get this working? These are the other map related Google APIs in the list.

enter image description here

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-05-12 01:17

Are you using https://developers.google.com/maps/documentation/ios/ also there is a nice documentation there. Yes you need to activate the IOS Maps SDK in the google api center when you log in

查看更多
男人必须洒脱
3楼-- · 2019-05-12 01:23

The API "Google Maps SDK for iOS" - it is only for integrating the "Google Maps SDK"...

If you want to “use” Directions.. you have to “activate” in the Google console: "Directions API” , too developers.google.com/maps/documentation/directions

Happy coding!

查看更多
登录 后发表回答