Reputation: 27
i want to show images on google map but i have no idea how to do it in android. same like as Panoramio .i have done so far,my android app capture images with latitude ,longitude save in sqllite database .i want to populate these images on google map according to their lat,long.
Upvotes: 0
Views: 4364
Reputation: 753
first you need to get the map, something like this
private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
then you can create a loop where you can add markers to the map
for (all the items you want to add) {
mMap.addMarker(new MarkerOptions()
.position(LatLng(coordinates))
.icon(BitmapDescriptorFactory.from where you have it));;
}
Check the info in the google developers site https://developers.google.com/maps/documentation/android/marker?hl=pt-PT
Upvotes: 1
Reputation: 7108
You can use something like this to create a Marker with an image as icon:
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);
}
Upvotes: 0