我正在使用 MKDirections 绘制从 A 点到 B 点的路线,并且我希望将 MKPointAnnotation 放在距起点的特定距离处。
例如,我有一个从 LA 到 NY 绘制 MKDirections 的 MKMap。然后,我想在用户决定采取的路线的 10 英里标记处放置一个大头针。
关于如何在特定距离使用所选路线找到纬度/经度的任何想法?
谢谢。
- (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;
}
}
}
}
这是可行的,因为我能够确定应该放置哪个步骤,但我的问题是如何确定步骤中的位置。