I want to show a marker of my own choice in place of that default blue colored icon. How can I change the same.
Currently I am adding it manually at current location.
@Override
public void onMyLocationChange(Location location) {
// Creating a LatLng object for the current location
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
// Showing the current location in Google Map
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(
latLng, 15);
googleMap.animateCamera(cameraUpdate);
marker = googleMap.addMarker(new MarkerOptions()
.position(latLng)
.title("Current Location(You)")
.snippet("Current")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.green_loc_icon))
.draggable(true));
}
});
It's explained in the documentation:
https://developers.google.com/maps/documentation/android/marker#change_the_default_marker
Please remember to remove the marker before adding a new one, otherwise each time you get an update for the user location you'll add a new marker on the map.
Since probably you're showing other markers on the map, hold a reference to the user current location marker and then use remove() method before creating a new instance.