Created
October 13, 2018 01:28
-
-
Save enjoyfan/1ab1bf8d9731ba4b94b0b7a0967763cf to your computer and use it in GitHub Desktop.
在外部地图软件中,按经纬度显示某个位置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <ul> | |
* <li>高德地图:com.autonavi.minimap</li> | |
* <li>腾讯地图:com.tencent.map</li> | |
* <li>谷歌地图:com.google.android.apps.maps</li> | |
* <li>百度地图:com.baidu.BaiduMap</li> | |
* </ul> | |
* | |
* @param mapAppPackage 地图软件的包名,传入null表示不指定地图软件 | |
* @param longitude 经度 | |
* @param latitude 纬度 | |
* @param locationName 位置名称 | |
*/ | |
private void showExternalMap(String mapAppPackage, double longitude, double latitude, String locationName) { | |
Uri uri = Uri.parse(String.format(Locale.US, "geo:%s,%s?q=%s", latitude, longitude, Uri.encode(locationName))); | |
Intent intent = new Intent(Intent.ACTION_VIEW, uri); | |
if (mapAppPackage != null) { | |
intent.setPackage(mapAppPackage); | |
} | |
if (intent.resolveActivity(getPackageManager()) != null) { | |
startActivity(intent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment