地图导航

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    //定位
    CLGeocoder * gercode =  [[CLGeocoder alloc]init];
    
    self.gercode = gercode;
    
//地理编码 [gercode geocodeAddressString:@"上海" completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) { CLPlacemark * place =[placemarks firstObject]; MKPlacemark * p = [[MKPlacemark alloc]initWithPlacemark:place]; MKMapItem * item1 = [[MKMapItem alloc]initWithPlacemark:p]; [gercode geocodeAddressString:@"北京" completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) { CLPlacemark * place1 = [placemarks firstObject]; MKPlacemark * p2 = [[MKPlacemark alloc]initWithPlacemark:place1]; MKMapItem * item2 = [[MKMapItem alloc]initWithPlacemark:p2]; //导航 [MKMapItem openMapsWithItems:@[item1 , item2] launchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsMapTypeKey:@2}]; }];

  

posted @ 2016-04-28 14:13  o.0...w  阅读(108)  评论(0编辑  收藏  举报