Google Directions API failing to return results in iOS

烈酒焚心 提交于 2020-01-23 10:57:09

问题


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.

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.


回答1:


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!




回答2:


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



来源:https://stackoverflow.com/questions/26195282/google-directions-api-failing-to-return-results-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!