在 android 中打开 google 地图
opening google map in android
我在这里打开带有 GPS 点的地图:
String geoUri = String.format("geo:%s,%s?z=15", Double.toString(lat), Double.toString(lng));
Uri geo = Uri.parse(geoURI);
Intent geoMap = new Intent(Intent.ACTION_VIEW, geo);
startActivity(geoMap);
google 聚焦在地图的正确位置,但未设置点。 google 地图缺少什么?
尝试使用geo:0,0?q=lat,lng(label)
在 given longitude and latitude with a string label
显示地图。
示例:"geo:0,0?q=34.99,-106.61"
示例代码:
Uri geoLocation = Uri.parse("geo:0,0?").buildUpon()
.appendQueryParameter("q", Double.toString(lat), Double.toString(lng))
.build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
// Error
}
详情请参考here。
我在这里打开带有 GPS 点的地图:
String geoUri = String.format("geo:%s,%s?z=15", Double.toString(lat), Double.toString(lng));
Uri geo = Uri.parse(geoURI);
Intent geoMap = new Intent(Intent.ACTION_VIEW, geo);
startActivity(geoMap);
google 聚焦在地图的正确位置,但未设置点。 google 地图缺少什么?
尝试使用geo:0,0?q=lat,lng(label)
在 given longitude and latitude with a string label
显示地图。
示例:"geo:0,0?q=34.99,-106.61"
示例代码:
Uri geoLocation = Uri.parse("geo:0,0?").buildUpon()
.appendQueryParameter("q", Double.toString(lat), Double.toString(lng))
.build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
// Error
}
详情请参考here。