NSString *address = dic[@"address"]; // 目標地址
if (type == 0) { // 百度地圖
NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin={{我的位置}}&destination=%@&mode=riding&src=趣Bar",address] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
NSURL *url = [NSURL URLWithString:urlString];
[[UIApplication sharedApplication] openURL:url];
}else if (type == 1) { // 高德地圖
NSString *urlString = [[NSString stringWithFormat:@"iosamap://path?sourceApplication=趣Bar&sid=BGVIS1&sname=%@&did=BGVIS2&dname=%@&dev=0&t=0",@"我的位置",address] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}else if (type == 2) { // 蘋果地圖
NSString *urlString = [[NSString stringWithFormat:@"http://maps.apple.com/?daddr=%@",address] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}
iOS 調用第三方應用地圖 筆記
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
推薦閱讀更多精彩內容
- 1、調用高德地圖 高德地圖應用包名:com.autonavi.minimap 高德地圖url說明: http://...
- 1.獲取地圖導航路線坐標 https://lbs.amap.com/console/show/picker 高德...