JSON-файл с маршрутом для Google Maps API

Я пытаюсь проложить путь на Google Maps. Написал функцию и файл json. Я думаю, что я сделал ошибку по координатам или по самому json. Пожалуйста, помогите мне найти ошибку в коде. Документация от Google немного непонятна для меня, поэтому я не могу полностью понять это правильно.

class MapView: UIView,CLLocationManagerDelegate,GMSMapViewDelegate {

    @IBOutlet var contentView: UIView!

    private func initView() {
        Bundle.main.loadNibNamed("MapView", owner: self, options: nil)
          contentView = mapView
        addSubview(contentView)

        contentView.frame = self.bounds

        locationManager = CLLocationManager()
        locationManager.delegate = self
        locationManager.requestWhenInUseAuthorization()
        locationManager.startUpdatingLocation()
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.startMonitoringSignificantLocationChanges()


        mapView.delegate = self
        mapView.isMyLocationEnabled = true

            self.drawPath()

    }
     let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: GMSCameraPosition.camera(withLatitude: 49, longitude: 98, zoom: 15.0))


    func drawPath()
    {
        let origin = "(49),(98)"
        let destination = "(49.3),(96)"

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

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

            let json = try? JSON(data: response.data!)
            let routes = json!["routes"].arrayValue

            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.map = self.mapView
            }
        }
    }
}

routes.json

[
{
    "error_message" : "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account",
    "routes" : [],
    "status" : "REQUEST_DENIED"
},
"overview_polyline" : {
    "points" : "knjmEnjunUbKCfEA?_@]@kMBeE@qIIoF@wH@eFFk@WOUI_@?u@j@k@`@EXLTZHh@Y`AgApAaCr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sTvEmEr@iCr@qDrAiFnCcEzCaE~D_@JmFdGQDwBvCeErEoD|BcFjC}DbEuD~D`@Zr@h@?d@Wr@}@vAgCbEaHfMqA`Cy@dAg@bAO`@gCi@w@W"
        },
{
        "summary" : "I-5 N and US-101 N",
        "warnings" : [],
        "waypoint_order" : []
    "status" : "OK"
    }
]

Всего 1 ответ


Сообщение об ошибке указывает на то, что вы не указали свой ключ API в запросе. С самого начала ответа ...

"error_message" : "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account"

Есть идеи?

10000