【发布时间】:2014-03-14 11:53:31
【问题描述】:
我想在谷歌地图上显示图像,但我不知道如何在 android 中进行。 和Panoramio一样 .到目前为止,我的android应用程序捕获带有纬度的图像,经度保存在sqllite数据库中 .我想根据它们的经纬度在谷歌地图上填充这些图像。
【问题讨论】:
标签: java android eclipse google-maps geotagging
我想在谷歌地图上显示图像,但我不知道如何在 android 中进行。 和Panoramio一样 .到目前为止,我的android应用程序捕获带有纬度的图像,经度保存在sqllite数据库中 .我想根据它们的经纬度在谷歌地图上填充这些图像。
【问题讨论】:
标签: java android eclipse google-maps geotagging
首先你需要得到地图,像这样
private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
然后您可以创建一个循环,您可以在其中向地图添加标记
for (all the items you want to add) {
mMap.addMarker(new MarkerOptions()
.position(LatLng(coordinates))
.icon(BitmapDescriptorFactory.from where you have it));;
}
查看谷歌开发者网站中的信息 https://developers.google.com/maps/documentation/android/marker?hl=pt-PT
【讨论】:
你可以使用这样的东西来创建一个带有图像作为图标的标记:
private MarkerOptions createMarker(LatLng position, String title, String snippet, String image_path) {
// Standard marker icon in case image is not found
BitmapDescriptor icon = BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED);
if (!image_path.isEmpty()) {
File iconfile = new File(image_path);
if (iconfile.exists()) {
BitmapDescriptor loaded_icon = BitmapDescriptorFactory
.fromPath(image_path);
if (loaded_icon != null) {
icon = loaded_icon;
} else {
Log.e(TAG, "loaded_icon was null");
}
} else {
Log.e(TAG, "iconfile did not exist: "
+ image_path);
}
} else {
Log.e(TAG, "iconpath was empty: "
+ image_path);
}
return new MarkerOptions().position(position)
.title(title)
.snippet(snippet).icon(icon);
}
【讨论】: