HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在iOS7中的MKMapView上显示MKRoute大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用MKDirectionsrequest在两点之间找到@L_34_0@mKRoute.
响应将使用以下代码显示在MKMapView上: @H_495_3@mKDirections *directions = [[MKDirections alloc] initWithrequest:request]; [directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response,NSError *error) { if (error) { NSLog(@"Error : %@",error); } else { [_mapView removeOverlays:_mapView.overlays]; for (MKRoute *route in response.routes) { [_mapView insertOverlay:route.polyline aTindex:0 level:MKOverlayLevelAboveroads]; } } }];

我的问题是,如果用户正在移动,如果有正确的方法更新MKRoute.我正在使用Atm

- (void)mapView:(MKMapView *)aMapView didupdateUserLOCATIOn:(MKUserLOCATIOn *)aUserLOCATIOn

识别移动,在这方法我@L_804_7@mKRoute覆盖,并计算和添加新的用户位置新.
我想知道是否有一种方法计算路线只有一次,并以编程方式更新覆盖?

编辑:
我发现这个https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKRouteStep_class/Reference/Reference.html#//apple_ref/occ/cl/MKRouteStep在苹果开发文档.
我想我必须做一些类似的事情

for (MKRoute *route in response.routes)
{
   for (MKRouteStep *step in route.steps) 
   {
      [_mapView insertOverlay:step.polyline aTindex:0 level:MKOverlayLevelAboveroads];
   }
}

但是如何识别实际用户位置背后的哪些步骤?

编辑:另一个选项可能是使用触发事件的定时器(删除旧的叠加层并添加新的叠加层).你怎么看?

[NSTimer scheduledTimerWithTimeInterval:15 target:self SELEctor:@SELEctor(addRouteOverlay) userInfo:nil repeats:YES];

解决方法

以下链接包含用于@L_447_2@mKMapView路线的示例代码,我们只需要在其中传递纬度和经度值.

https://github.com/kadirpekel/MapWithRoutes

大佬总结

以上是大佬教程为你收集整理的在iOS7中的MKMapView上显示MKRoute全部内容,希望文章能够帮你解决在iOS7中的MKMapView上显示MKRoute所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。