iOS 硬件 导航 - APP去做

来源:互联网 发布:域名可以干嘛 编辑:程序博客网 时间:2024/06/05 05:11

 跳转到高德地图   关键词 MKapItem 



1. [MKMapItemopenMapsWithItems:itemArray launchOptions:launchDic];

2.lauchOptions == 属性字典  MKLaunchOptioan

NSDictionary*launchDic = @{MKLaunchOptionsShowsTrafficKey:@(YES),
                               
MKLaunchOptionsMapTypeKey:@(MKMapTypeStandard),
                               
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving
                               };

3.array = MKMapItem allck initWith == MKPlacemark allock init == CLPlacemark == 地理编码和反地理编码






-(void)touchesBegan:(NSSet<UITouch*> *)touches withEvent:(UIEvent*)event{


    [
self.geocodegeocodeAddressString:@"青岛"completionHandler:^(NSArray<CLPlacemark*> * _Nullable placemarks,NSError* _Nullable error) {

       
CLPlacemark *startPM = [placemarksfirstObject];

        [
self.geocodegeocodeAddressString:@"济南"completionHandler:^(NSArray<CLPlacemark*> * _Nullable placemarks,NSError* _Nullable error) {

           
CLPlacemark *endPM = [placemarksfirstObject];
           
           
            [
selfgetPlaceMarkWithStartPM:startPMWithEndPM:endPM];
           
        }];


    }];


}


- (
void)getPlaceMarkWithStartPM:(CLPlacemark*)startPM WithEndPM:(CLPlacemark*)endPM{




   
MKPlacemark *startMK = [[MKPlacemarkalloc]initWithPlacemark:startPM];

   
MKMapItem *startItem = [[MKMapItemalloc]initWithPlacemark:startMK];

   
MKPlacemark *endMK = [[MKPlacemarkalloc]initWithPlacemark:endPM];

   
MKMapItem *endItem = [[MKMapItemalloc]initWithPlacemark:endMK];

   
NSArray *itemArray =@[startItem,endItem];

   
NSDictionary *launchDic =@{MKLaunchOptionsShowsTrafficKey:@(YES),
                               
MKLaunchOptionsMapTypeKey:@(MKMapTypeStandard),
                               
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving
                               
};

    [
MKMapItemopenMapsWithItems:itemArray launchOptions:launchDic];
}
 
0 0
原创粉丝点击