Swift, MapKit, CLLocation 如何避开收费公路

Swift, MapKit, CLLocation how to avoid toll roads

我有这段代码可以更新用户的位置并将其保存在数组中,我现在如何确定用户是否在 toll/highway 道路上?

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]
    }

您可能想尝试查看 MKDirectionsResponse 对象。它包含一个 MKRoute 对象数组,每个 MKRoute 都有一个 advisoryNotices (字符串),其中包含有关路线的信息。不能保证它总是有通行费信息,但它可能....