Set Map Marker to Custom Color Android
I am making an application that adds pins to the map at specific points. I want the color of my contacts to match the theme colors of our application. Sorry I'm really a noob
int color = Color.rgb(255, 201, 14);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
final LatLng PERTH = new LatLng(40, -80);
Marker perth = mMap.addMarker(new MarkerOptions()
.position(PERTH)
.title("MY PIN")
.snippet("MAGGIE EATS SNAKE SKINS")
.draggable(true)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin))
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.color)));
..icon (BitmapDescriptorFactory.defaultMarker (BitmapDescriptorFactory.color))); does not work. This will prevent me from inserting a special color here. How can i do this? Thank:)
source to share
defaultMarker()
the method allows you to set your own color, but only by providing a hue value. According to android documentation:
(Hue) Value must be greater than or equal to 0 and less than 360
If you know the Hex or RGB value for your application theme, then you need to do some calculations (see example ) or just use some free online converter . In your case, the hue value will be 47.
Also, there is no need to set the .icon () property twice in your code.
source to share