I'm using MKDirections to draw a route from point A to point B, and I'm looking to put a MKPointAnnotation at specific distance from the starting point.
For example, I have a MKMap with MKDirections drawn from LA to NY. I then would like to place a pin at the 10 mile marker for the route the user has decided to take.
Any thoughts on how to find the lat/long, using the chosen route at a specific distance?
Thanks.
- (void)showDirections:(MKDirectionsResponse *)response
{
NSInteger iDistance = 0;
BOOL bPointinStep = NO;
self.response = response;
for (MKRoute *route in _response.routes)
{
NSLog(@"route.distance: %.0f", route.distance);
responseNumber = responseNumber + 1;
[_mapView addOverlay:route.polyline level:MKOverlayLevelAboveRoads];
for (MKRouteStep *step in route.steps)
{
iDistance = iDistance + step.distance;
NSLog(@"iDistance: %.0ld", (long)iDistance);
NSLog(@"step.distance: %.0f", step.distance);
NSLog(@"%@", step.instructions);
if (iProgress < iDistance && !bPointinStep) {
NSLog(@"pin point is on this step");
bPointinStep = YES;
}
}
}
}
This works, as I'm able to determine which step the pin point should be placed, but my question is on how to determine where within the step.