Post not yet marked as solved
Post marked as unsolved with 0 replies, 418 views
I am using MapKit to show navigation directions between source and destination location like in apple and google maps.
With the help of MKRoute object, i am showing distance required for the user to make his next turn in x distance.
For distance i'm using the below method.
Eg: Take Right(route.step.instructions) 0.8 mi (route.step.distance)
for monitoredRegions in locationManager.monitoredRegions {
locationManager.stopMonitoring(for: monitoredRegions)
}
let steps = route.steps
self.steps = steps
for i in 0 ..< steps.count {
let step = steps[i]
print(step.instructions)
print(step.distance)
let region = CLCircularRegion(center: step.polyline.coordinate,
radius: 20, identifier: "\(i)")
locationManager.startMonitoring(for: region)
}
stepCounter += 1
let directionText = steps[stepCounter].instructions
self.titleLabel.text = directionText
self.distanceLabel.text = "\(steps[stepCounter].distance)"
}
I want to change the distance as user navigates closer to the take the right turn, and minimise the distance from 0.8 to 0.0 and update it continuously in real time.
Kindly check the image and let me know a simple way to achieve it.