ios - 谷歌地图方向

标签 ios swift google-maps alamofire

我想在谷歌地图上显示路线,但出现此错误

我只调用了一次这个api,但是第一次出现这个错误

我该怎么办?

OVER_QUERY_LIMIT

let url = "https://maps.googleapis.com/maps/api/directions/json?origin=\(origin)&destination=\(destination)&mode=driving"

    Alamofire.request(url).responseJSON { response in
        //print(response.request as Any)  // original URL request
        //print(response.response as Any) // HTTP URL response
        //print(response.data as Any)     // server data
        //print(response.result as Any)   // result of response serialization

        let json = try! JSON(data: response.data!)
        let routes = json["routes"].arrayValue
        print(json)
        // print route using Polyline

        DispatchQueue.global(qos: .default).async(execute: {() -> Void in
            // Do something...
            DispatchQueue.main.async(execute: {() -> Void in
                // self.hideHUD()
            })
        })
        for route in routes
        {
            let routeOverviewPolyline = route["overview_polyline"].dictionary
            let points = routeOverviewPolyline?["points"]?.stringValue
            let path = GMSPath.init(fromEncodedPath: points!)
            let polyline = GMSPolyline.init(path: path)
            polyline.strokeWidth = 4
            polyline.strokeColor = #colorLiteral(red: 0, green: 0.4784313725, blue: 1, alpha: 1)
            polyline.map = self.mapView

        }

最佳答案

从 2018 年 9 月 10 日开始,巴西、加拿大和印度自助服务客户的使用量将限制为每月 200 美元。这种情况是暂时的。有关详细信息,请参阅 map 常见问题解答。新的即用即付定价计划现已对 Google Maps Platform API 生效。

Understanding Billing for Maps, Routes, and Places

关于ios - 谷歌地图方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52677040/

相关文章:

ios - 如何在 swift 中将字符索引从布局管理器转换为字符串比例

ios - 使用 Swift 4.2 解析嵌套 JSON

swift - Alamofire SSL 失败

javascript - 在网站中加载谷歌地图的最佳方式

ios - UILocalNotification 文本显示在通知中心后如何更改?

ios - 为 iOS9 启用了位码的静态 iOS 框架

swift - 委托(delegate)函数在此代码中被破坏。我应该怎么做才能解决它?

ios - 为什么 Swift4 会转换一个 UIButton 数组!到 [UIButton?] 类型?

java - 为什么谷歌地图上的阴影会被裁剪?

ios - 如何在另一个函数中调用一个函数?