1.国内常用的三家地图软件
- baidu("com.baidu.BaiduMap", "百度地图"),
- gaode("com.autonavi.minimap", "高德地图"),
- tengxun("com.tencent.map", "腾讯地图");
2.判断地图软件是否安装
public static boolean isAppInstalled(@NonNull final String pkgName) {
PackageManager packageManager = Utils.getApp().getPackageManager();
try {
return packageManager.getApplicationInfo(pkgName, 0) != null;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return false;
}
}
3.打开地图标注指定地点
private const val action = "android.intent.action.VIEW"
private const val category = "android.intent.category.DEFAULT"
fun goBaidumap(
context: Context,
poiname: String?,
addr: String?,
longitude: Double?,
latitude: Double?
) {
val naviIntent = Intent(
action,
Uri.parse("baidumap://map/marker?location=$latitude,$longitude&title=$poiname&content=$addr&coord_type=gcj02&traffic=on&src=$appname")
).apply {
addCategory(category)
setPackage(NavigationEnum.baidu.packageName)
}
context.startActivity(naviIntent)
}
fun goAmap(
context: Context,
poiname: String?,
addr: String?,
longitude: Double?,
latitude: Double?
) {
val naviIntent = Intent(
action,
Uri.parse("androidamap://viewMap?sourceApplication=$appname&poiname=$poiname&lat=$latitude&lon=$longitude&dev=0")
).apply {
addCategory(category)
setPackage(NavigationEnum.gaode.packageName)
}
context.startActivity(naviIntent)
}
fun goTencentmap(
context: Context,
poiname: String?,
addr: String?,
longitude: Double?,
latitude: Double?
) {
val naviIntent = Intent(
action,
Uri.parse("qqmap://map/marker?marker=coord:$latitude,$longitude;title:$poiname;addr:$addr&referer=$appname")
).apply {
addCategory(category)
setPackage(NavigationEnum.tengxun.packageName)
}
context.startActivity(naviIntent)
}
4.弹窗就自己写一个吧
Screenshot_2020-03-20-13-48-32-937.jpg
网友评论