1.现在info.plist里面如下图所示添加
2.在下图输入框中输入地名,然后点击前往目的地会出现如下图所示。(如果你不知道地方名如何转化为经纬度请看我的另一篇博客:http://blog.csdn.net/chenyongkai1/article/details/51891135)
3.添加下面的代理
UIActionSheetDelegate,CLLocationManagerDelegate
4.下面是最核心代码
先调用下面的方法
- (void)showMapNavigationViewWithtargetLatitude:(double)targetLatitude targetLongitute:(double)targetLongitute toName:(NSString *)name;
4.调用完最核心的代码后下面的所有的主干方法都在在上面的方法执行后都会运行一次。
(NSArray *)checkHasOwnApp{
NSArray *mapSchemeArr =@[@"iosamap://navi",@"baidumap://map/",@"qqmap://"];
NSMutableArray *appListArr = [[NSMutableArrayalloc] initWithObjects:@"苹果地图",nil];
for (int i =0; i < [mapSchemeArr count]; i++) {
if ([[UIApplicationsharedApplication] canOpenURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@",[mapSchemeArrobjectAtIndex:i]]]]) {
if (i ==0) {
[appListArr addObject:@"高德地图"];
}elseif (i == 1){
[appListArr addObject:@"百度地图"];
}elseif (i == 2){
[appListArr addObject:@"腾讯地图"];
}elseif (i == 3){
}
}
}
return appListArr;
}
- (void)showMapNavigationViewFormcurrentLatitude:(double)currentLatitude currentLongitute:(double)currentLongitute TotargetLatitude:(double)targetLatitude targetLongitute:(double)targetLongitute toName:(NSString *)name{
_currentLatitude = currentLatitude;
_currentLongitute = currentLongitute;
_targetLatitude = targetLatitude;
_targetLongitute = targetLongitute;
_name = name;
NSArray *appListArr = [JXMapNavigationViewcheckHasOwnApp];
NSString *sheetTitle = [NSStringstringWithFormat:@"导航到 %@",name];
UIActionSheet *sheet;
if ([appListArrcount] == 1) {
sheet = [[UIActionSheet