显示路由时出错 - MapKit

时间:2017-12-29 04:40:16

标签: ios swift3 mapkit

这是我代码的一部分。我试图在两点之间显示一些路线。除路线外,一切正常。

  

[MKRoutePolyline interiorPolygons] :无法识别的选择器已发送至   实例

    let directionRequest = MKDirectionsRequest()
    directionRequest.source = sourceItem
    directionRequest.destination = destItem
    directionRequest.requestsAlternateRoutes = true
    directionRequest.transportType = .automobile

    let directions = MKDirections(request: directionRequest)
    directions.calculate(completionHandler: {
        response, error in
        guard let response = response else {
            if error != nil {
                print("Error")
            }
            return
        }
        let route = response.routes[0]
        self.mapView.add(route.polyline, level: .aboveRoads)

        let rekt = route.polyline.boundingMapRect
        self.mapView.setRegion(MKCoordinateRegionForMapRect(rekt), animated: true)
    })

func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
        let renderer = MKPolygonRenderer(overlay: overlay)
        renderer.strokeColor = UIColor.blue
        renderer.lineWidth = 5.0

        return renderer
    }

0 个答案:

没有答案