ios Map 开发笔记 四 导航画线
来源:互联网 发布:女生发型 知乎 编辑:程序博客网 时间:2024/05/02 05:03
- (void)viewDidLoad
{
self.mapView.delegate =self;
CLLocationCoordinate2D centerPort = {45.748637,126.699891};
MKCoordinateSpan coordinateSpin =MKCoordinateSpanMake(0.05,0.05);
MKCoordinateRegion coordinateRegion = MKCoordinateRegionMake(centerPort, coordinateSpin);
[self.mapView setRegion:coordinateRegion];
[self.mapView regionThatFits:coordinateRegion];
CLLocationCoordinate2D redRocksAmphitheatre =CLLocationCoordinate2DMake(45.748637,126.699891);
MKPlacemark * redRocksPlacemark = [[MKPlacemarkalloc]initWithCoordinate:redRocksAmphitheatreaddressDictionary:nil];
MKMapItem *redRocksItem = [[MKMapItemalloc]initWithPlacemark:redRocksPlacemark];
redRocksItem.name = @"red rocks";
CLLocationCoordinate2D sportsAuthorityField =CLLocationCoordinate2DMake(45.747747,126.658671);
MKPlacemark * sportsAuthorityPlacemark = [[MKPlacemarkalloc]initWithCoordinate:sportsAuthorityFieldaddressDictionary:nil];
MKMapItem * sportsAuthorityItem = [[MKMapItemalloc]initWithPlacemark:sportsAuthorityPlacemark];
sportsAuthorityItem.name = @"sports authority";
[self findDirectionsFrom:redRocksItemto:sportsAuthorityItem];
[superviewDidLoad];
}
-(void)findDirectionsFrom:(MKMapItem *)sources to:(MKMapItem*)destination
{
MKDirectionsRequest *request = [[MKDirectionsRequestalloc]init];
request.source = sources;
request.destination = destination;
request.requestsAlternateRoutes =NO;
MKDirections *directions = [[MKDirectionsalloc]initWithRequest:request];
[directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response,NSError *error)
{
if (error)
{
NSLog(@"we get an error %@",error);
}
else
{
[self showDirectionsOnMap:response];
}
}];
}
-(MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
{
if ([overlayisKindOfClass:[MKPolyline class]])
{
MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc]initWithOverlay:overlay ];
renderer.lineWidth = 3;
renderer.strokeColor = [UIColorredColor];
return renderer;
}
else
{
return nil;
}
}
-(void)showDirectionsOnMap :(MKDirectionsResponse *)respones
{
self.respones = respones;
for (MKRoute * route in self.respones.routes) {
[self.mapViewaddOverlay:route.polyline level:MKOverlayLevelAboveRoads];
}
[self.mapViewaddAnnotation:self.respones.source.placemark];
[self.mapViewaddAnnotation:self.respones.destination.placemark];
}
- ios Map 开发笔记 四 导航画线
- 导航/画线
- IOS开发-画线画图
- IOS开发-画线画图
- google map开发学习笔记(四)
- google map开发学习笔记(四)
- iOS 开发流程笔记(四)
- 【iOS开发-画线】使用贝塞尔曲线(UIBezierPath)画线
- iOS开发UINavigation系列四——导航控制器UINavigationController
- iOS 根据地图上的点画线 画导航
- ios Map 开发笔记二 地图
- IOS开发(80)之画线
- ios画线
- IOS 画线
- iOS 画线
- IOS 画线
- iOS 画线
- iOS 画线
- There's more to mathematics than rigour and proofs (作者:陶哲轩)
- 树莓派远程控制灯
- hadoop2的参数配置实例
- 对高德,马云为何非得全资收购?
- linux shell实现随机数多种方法(date,random,uuid)
- ios Map 开发笔记 四 导航画线
- UVa 10534 Wavio Sequence
- FreeSWITCH技巧:如何向通话的另一方号码发送dtmf?
- 单元测试本质:面向逻辑块
- 互联网公司该向东莞学什么?
- 锁和并发性----锁
- FreeSWITCH: JAVA模块的简单应用(mod_java)
- 使用Netbeans创建java Web项目
- CentOS 6.3 安装Apache