J'utilise des cadres d'emplacement de base UImapkit & Comment vais-je obtenir la distance totale POLYLIGNE & a voyagé le tempsComment calculer la distance parcourue par l'utilisateur de l'emplacement actuel rapide 3.0
ce mon code
func locationManager(_ manager: CLLocationManager!, didUpdateToLocation newLocation: CLLocation!, fromLocation oldLocation: CLLocation!) {
if let oldLocationNew = oldLocation as CLLocation?{
let oldCoordinates = oldLocationNew.coordinate
let newCoordinates = newLocation.coordinate
var area = [oldCoordinates, newCoordinates]
print(area)
let polyline = MKPolyline(coordinates: &area, count: area.count)
mkMapView.add(polyline)
}
//calculation for location selection for pointing annoation
if (previousLocation as CLLocation?) != nil{
if previousLocation.distance(from: newLocation) > 10 {
addAnnotationsOnMap(newLocation)
previousLocation = newLocation
}
}else{
//case if previous location doesn't exists
addAnnotationsOnMap(newLocation)
previousLocation = newLocation
}
}