地图导航
-(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}]; }];