0

我有這段代碼來更新和保存用戶在陣列上的位置現在如何確定用戶是否在收費/高速公路上?Swift,MapKit,CLLocation如何避免收費公路

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 

    let userLocation: CLLocation = locations[0] as CLLocation 
    userLocationForDirections = locations[0] as CLLocation 

    manager.startUpdatingLocation() 
    var userLatitude = (userLocation.coordinate.latitude) 
    var userLongitude = (userLocation.coordinate.longitude) 
    userMoves = [userLatitude, userLongitude] 
    } 

回答

1

您可能想試試看MKDirectionsResponse對象。它包含一組MKRoute對象,並且每個MKRoute都有一個advisoryNotices(字符串),其中包含有關該路線的信息。不保證它總是有收費信息,但它可能....