Using the MarkerOptions
class, we can the and icon of the marker. The following code both the icon and color of the marker.
To change the color of the marker, please refer to the following code:
private void addMarker(Memory memory) {
Marker marker = mMap.addMarker(new MarkerOptions()
.draggable(true).icon(BitmapDescriptorFactory.defaultMarker
(BitmapDescriptorFactory.HUE_CYAN)).alpha(0.7f)
.position(new LatLng(memory.latitude, memory.longitude)));
mMemories.put(marker.getId(), memory);
}
We can now see that the marker color is changed from red to cyan with transparency. If you wish to remove the transparency, you can remove the .alpha()
value passed to marker options:
Changed marker color
To the to an icon the drawable
directory, check following code:
private void addMarker(Memory memory) {
Marker marker = mMap.addMarker(new MarkerOptions()
.draggable(true).icon(BitmapDescriptorFactory.fromResource...