How to add marker on google maps android?
Look here in Google Maps example https://developers.google.com/maps/documentation/android-api/marker
If you want to add marker when clicking you can also look here: http://wptrafficanalyzer.in/blog/adding-marker-on-touched-location-of-google-maps-using-android-api-v2-with-supportmapfragment/
The concept is to do like the folowing code:
// Setting a click event handler for the map
googleMap.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
// Creating a marker
MarkerOptions markerOptions = new MarkerOptions();
// Setting the position for the marker
markerOptions.position(latLng);
// Setting the title for the marker.
// This will be displayed on taping the marker
markerOptions.title(latLng.latitude + " : " + latLng.longitude);
// Clears the previously touched position
googleMap.clear();
// Animating to the touched position
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
// Placing a marker on the touched position
googleMap.addMarker(markerOptions);
}
});
//Show Marker on a Location
googleMap.addMarker(new MarkerOptions().position(TIMES_SQUARE));
//Change Default Color of Marker
googleMap.addMarker(new MarkerOptions()
.position(BROOKLYN_BRIDGE)
.title("First Pit Stop")
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
//Replace Default Marker Icon with Custom Image
googleMap.addMarker(new MarkerOptions()
.position(WALL_STREET)
.title("Wrong Turn!")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.my_flag)));