判断百度地图及高德地图是否安装
2015-04-18 15:56
183 查看
+ (void)jumpToMapWithStartLat:(double)startLat
startLong:(double)startLong endLat:(double)endLat
endLong:(double)endLong {
BOOL
hasBaiduMap = NO;
BOOL
hasGaodeMap = NO;
//是否安装百度地图
if
([[UIApplication
sharedApplication]
canOpenURL:[NSURL
URLWithString:@"baidumap://map/"]]){
hasBaiduMap = YES;
}
//是否安装高德地图
if
([[UIApplication
sharedApplication]
canOpenURL:[NSURL
URLWithString:@"iosamap://"]]){
hasGaodeMap = YES;
}
if
(hasBaiduMap)
{
//跳到百度地图客户端
NSString
*urlString = [[NSString
stringWithFormat:@"baidumap://map/direction?origin=latlng:%f,%f|name:我的位置&destination=latlng:%f,%f|name:终点&mode=driving",startLat,
startLong, endLat, endLong]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication
sharedApplication]
openURL:[NSURL
URLWithString:urlString]];
}
else
if (hasGaodeMap)
{
//跳到高德地图客户端
NSString
*urlString = [[NSString
stringWithFormat:@"iosamap://path?sourceApplication=%@&backScheme=%@&sid=BGVIS1&slat=%f&slon=%f&sname=%@&did=BGVIS2&dlat=%f&dlon=%f&dname=%@&dev=0&m=0&t=0",@"小美到家",
@"xmdp5bCP576O5bqX6ZO6", startLat, startLong,
@"起点", endLat, endLong,
@"终点"]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication
sharedApplication]
openURL:[NSURL
URLWithString:urlString]];
} else
{
NSString
*urlString = [[NSString
stringWithFormat:@"http://map.baidu.com?destination=latlng:%f,%f|name:终点&mode=driving",endLat,
endLong] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication
sharedApplication]
openURL:[NSURL
URLWithString:urlString]];
}
}
startLong:(double)startLong endLat:(double)endLat
endLong:(double)endLong {
BOOL
hasBaiduMap = NO;
BOOL
hasGaodeMap = NO;
//是否安装百度地图
if
([[UIApplication
sharedApplication]
canOpenURL:[NSURL
URLWithString:@"baidumap://map/"]]){
hasBaiduMap = YES;
}
//是否安装高德地图
if
([[UIApplication
sharedApplication]
canOpenURL:[NSURL
URLWithString:@"iosamap://"]]){
hasGaodeMap = YES;
}
if
(hasBaiduMap)
{
//跳到百度地图客户端
NSString
*urlString = [[NSString
stringWithFormat:@"baidumap://map/direction?origin=latlng:%f,%f|name:我的位置&destination=latlng:%f,%f|name:终点&mode=driving",startLat,
startLong, endLat, endLong]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication
sharedApplication]
openURL:[NSURL
URLWithString:urlString]];
}
else
if (hasGaodeMap)
{
//跳到高德地图客户端
NSString
*urlString = [[NSString
stringWithFormat:@"iosamap://path?sourceApplication=%@&backScheme=%@&sid=BGVIS1&slat=%f&slon=%f&sname=%@&did=BGVIS2&dlat=%f&dlon=%f&dname=%@&dev=0&m=0&t=0",@"小美到家",
@"xmdp5bCP576O5bqX6ZO6", startLat, startLong,
@"起点", endLat, endLong,
@"终点"]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication
sharedApplication]
openURL:[NSURL
URLWithString:urlString]];
} else
{
NSString
*urlString = [[NSString
stringWithFormat:@"http://map.baidu.com?destination=latlng:%f,%f|name:终点&mode=driving",endLat,
endLong] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication
sharedApplication]
openURL:[NSURL
URLWithString:urlString]];
}
}
相关文章推荐
- 判断是否安装百度地图和高德地图
- 判断手机是否安装高德/百度地图
- 判断手机是否安装高德/百度地图
- iOS-82-自己APP地图内检测是否安装了其他地图(百度地图、高德地图、苹果地图),以及跳转
- 安卓开发——判断本机是否安装有某应用(qq、微信、百度地图等)
- 判断系统是否安装某APP - 以高德地图为例
- 判断iOS用户手机是否安装百度、高德地图App
- baidumap 判断是否安装百度地图客户端
- Android打开指定好友聊天,并可以判断是否安装qq
- 判断一个应用程序是否已安装
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- android 判断应用程序是否已安装
- 浏览器网页判断手机是否安装IOS/Android客户端程序
- Android判断是否安装某App
- C#判断某个软件是否已安装实现代码分享
- Inno Setup安装、卸载时判断是否程序正在运行
- Android 判断app是否安装
- Android WebView播放flash(判断是否安装flash插件)
- 获取手机中所有已安装的应用,并判断是否系统应用
- 在html页面中判断本地app是否安装并打开