使用Apple Maps中的MKpolyline如何使应用根据行进方向移动或旋转?

时间:2018-10-04 17:28:17

标签: ios swift mapkit mkpolyline

在添加MKpolyline时,我使用了地图的以下属性将地图旋转到行进的方向,但是没有任何帮助。.

mapView.setUserTrackingMode(.followWithHeading, animated: true)

let mapCamera = MKMapCamera(lookingAtCenter: dongleCoordinates!, 
                 fromDistance: 500, pitch: 20, heading: 0)
 mapView.setCamera(mapCamera, animated: true)

//添加折线

mapView?.delegate = self
var locations = places.map { $0.coordinate }
print("Number of locations: \(locations.count)")
let polyline = MKPolyline(coordinates: &locations, count: 
                 locations.count)

mapView?.addOverlay(polyline)

// MKMapViewDelegate

func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {

    let renderer = MKPolylineRenderer(overlay: overlay)
    renderer.strokeColor = DLConstants.colors.blue
    renderer.lineWidth = 3.0

    return renderer
}

0 个答案:

没有答案