在添加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
}