该服务拒绝使用此应用程序的指示服务

时间:2017-03-10 18:32:33

标签: ios swift xcode google-maps

我想使用此库将谷歌地图用作路由器。

https://github.com/poulpix/PXGoogleDirections

我的api密钥:

AIzaSyAHQPNUQuSYLUsa3JxVxTyUH_Lab-7EPxc

我从这个链接获得了这个api密钥:

https://console.developers.google.com/apis/credentials

enter image description here

我的代码:

  override func viewDidLoad() {
    super.viewDidLoad()

    initialValues()

    let directionsAPI = PXGoogleDirections(apiKey: "AIzaSyAHQPNUQuSYLUsa3JxVxTyUH_Lab-7EPxc",
                            from: PXLocation.coordinateLocation(CLLocationCoordinate2DMake(37.331690, -122.030762)),
                                           to: PXLocation.specificLocation("Googleplex", "Mountain View", "United States"))


    directionsAPI.calculateDirections({ response in
        switch response {
        case let .error(_, error):
            // Oops, something bad happened, see the error object for more information
            print("errorrrr \(error)")
            break
        case let .success(request, routes):
            // Do your work with the routes object array here
            print("ok map")
            break
        }
    })

}

我的错误:

errorrrr Error Domain=PXGoogleDirectionsErrorDomain Code=6 "The service denied use of the directions service by this application" UserInfo={NSLocalizedDescription=The service denied use of the directions service by this application}

另一个问题,如果我的密钥工作正常,地图会显示在哪里?我认为它需要一个空的view

1 个答案:

答案 0 :(得分:1)

enter image description here您还需要启用地点API。

步骤: - 转到console-> credential-> library-> place library-> enabled。