我尝试使用以下代码添加从用户位置到目的地的折线,我确信我已经符合委托并确保用户在授权状态下处于 authorizedAlway 模式。但是,控制台生成了此错误消息,显示“ [UserSession] maps short session requested but session sharing is not enabled ”我找不到任何与如何解决此错误相关的信息。
func generatePolyLine(toDestination destination: MKMapItem) {
let request = MKDirections.Request()
//start from the user's current location to find the ride
request.source = MKMapItem.forCurrentLocation()
request.destination = destination
request.transportType = .automobile
let directionRequest = MKDirections(request: request)
directionRequest.calculate { response, error in
if let error = error {
print("Error calculating direction request \(error)")
}
guard let response = response else { return }
self.route = response.routes.first
guard let polyLine = self.route?.polyline else { return }
self.mapView.addOverlay(polyLine, level: .aboveRoads)
}
}