我想在谷歌地图上显示图像,但我不知道如何在Android中做到这一点。 与Panoramio相同 .i到目前为止,我的Android应用程序捕获图像与纬度,经度保存在sqllite数据库中 .i想要根据他们的lat长期在谷歌地图上填充这些图片。
答案 0 :(得分:1)
首先你需要得到这样的地图
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));;
}
检查google开发者网站中的信息 https://developers.google.com/maps/documentation/android/marker?hl=pt-PT
答案 1 :(得分:0)
您可以使用类似的内容创建标记为图标的标记:
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);
}