跳转到高德地图 关键词 MKapItem
1.
[
MKMapItem
openMapsWithItems
:itemArray
launchOptions
:launchDic];
2.lauchOptions == 属性字典 MKLaunchOptioan
NSDictionary
*launchDic =
@{
MKLaunchOptionsShowsTrafficKey
:
@(YES)
,
MKLaunchOptionsMapTypeKey : @( MKMapTypeStandard ) ,
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving
MKLaunchOptionsMapTypeKey : @( MKMapTypeStandard ) ,
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving
};
3.array = MKMapItem allck initWith ==
MKPlacemark allock init ==
CLPlacemark == 地理编码和反地理编码
-(
void
)touchesBegan:(
NSSet
<
UITouch
*> *)touches withEvent:(
UIEvent
*)event{
[ self . geocode geocodeAddressString : @" 青岛 " completionHandler :^( NSArray < CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
CLPlacemark *startPM = [placemarks firstObject ];
[ self . geocode geocodeAddressString : @" 济南 " completionHandler :^( NSArray < CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
CLPlacemark *endPM = [placemarks firstObject ];
[ self getPlaceMarkWithStartPM :startPM WithEndPM :endPM];
}];
}];
}
- ( void )getPlaceMarkWithStartPM:( CLPlacemark *)startPM WithEndPM:( CLPlacemark *)endPM{
MKPlacemark *startMK = [[ MKPlacemark alloc ] initWithPlacemark :startPM];
MKMapItem *startItem = [[ MKMapItem alloc ] initWithPlacemark :startMK];
MKPlacemark *endMK = [[ MKPlacemark alloc ] initWithPlacemark :endPM];
MKMapItem *endItem = [[ MKMapItem alloc ] initWithPlacemark :endMK];
NSArray *itemArray = @[ startItem,endItem ] ;
NSDictionary *launchDic = @{ MKLaunchOptionsShowsTrafficKey : @(YES) ,
MKLaunchOptionsMapTypeKey : @( MKMapTypeStandard ) ,
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving
} ;
[ MKMapItem openMapsWithItems :itemArray launchOptions :launchDic];
[ self . geocode geocodeAddressString : @" 青岛 " completionHandler :^( NSArray < CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
CLPlacemark *startPM = [placemarks firstObject ];
[ self . geocode geocodeAddressString : @" 济南 " completionHandler :^( NSArray < CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
CLPlacemark *endPM = [placemarks firstObject ];
[ self getPlaceMarkWithStartPM :startPM WithEndPM :endPM];
}];
}];
}
- ( void )getPlaceMarkWithStartPM:( CLPlacemark *)startPM WithEndPM:( CLPlacemark *)endPM{
MKPlacemark *startMK = [[ MKPlacemark alloc ] initWithPlacemark :startPM];
MKMapItem *startItem = [[ MKMapItem alloc ] initWithPlacemark :startMK];
MKPlacemark *endMK = [[ MKPlacemark alloc ] initWithPlacemark :endPM];
MKMapItem *endItem = [[ MKMapItem alloc ] initWithPlacemark :endMK];
NSArray *itemArray = @[ startItem,endItem ] ;
NSDictionary *launchDic = @{ MKLaunchOptionsShowsTrafficKey : @(YES) ,
MKLaunchOptionsMapTypeKey : @( MKMapTypeStandard ) ,
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving
} ;
[ MKMapItem openMapsWithItems :itemArray launchOptions :launchDic];
}