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 调用第三方应用地图【笔记】
最新推荐文章于 2023-03-15 09:09:35 发布