What color is available to make a marker on Android map?
How many colors are there and how to write the code of color?
This is how to make a default marker
Marker melbourne = mMap.addMarker(new MarkerOptions().position(MELBOURNE)
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
and these are the constants you can use
float HUE_AZURE
float HUE_BLUE
float HUE_CYAN
float HUE_GREEN
float HUE_MAGENTA
float HUE_ORANGE
float HUE_RED
float HUE_ROSE
float HUE_VIOLET
float HUE_YELLOW
-
4
-
2Those are just a few predefined hues. Since the
defaultMarker()
method takes afloat
, you can supply any value within a range of[0...360]
. – MH. Sep 29 '13 at 9:29 -
4
-
2According to Google Maps Android SDK's documentation, only hue can be used to color a marker
BitmapDescriptorFactory.defaultMarker(float hue)
. How can one get a proper color by considering only hue out of HSV? Either Google has badly implemented the coloring functionality or I am gravely mistaken. I really hope it is not the former. It is such a pain either way! – Lingaraju E V Mar 2 at 21:10 -
1@sunlover3 there's no grey hue value in the HSB/HSL encodings of RGB – LeonardoSibela Jun 20 at 20:23
Here is a method I am using to generate dynamic Hue
colors for markers based on given String
color.
May be useful for someone :)
Marker melbourne = mMap.addMarker(new MarkerOptions().position(MELBOURNE)
.icon(getMarkerIcon("#ff2299")));
// method definition
public BitmapDescriptor getMarkerIcon(String color) {
float[] hsv = new float[3];
Color.colorToHSV(Color.parseColor(color), hsv);
return BitmapDescriptorFactory.defaultMarker(hsv[0]);
}
-
6
DETAILED ANSWER!
float hue = 120; //(Range: 0 to 360)
Marker melbourne = mMap.addMarker(new MarkerOptions().position(MELBOURNE)
.icon(BitmapDescriptorFactory
.defaultMarker(hue)));
You can give any hue value ranging from 0 to 360, some constants are defined here (https://developers.google.com/android/reference/com/google/android/gms/maps/model/BitmapDescriptorFactory)
BEST WAY! to find required hue(that matches your required color).
Open this image in Paint.Net/Photoshop editor (or other)
Goto hue options in your photo editor and slide hue bar and note best matched hue value.
For Paint.net (Adjustments -> Hue/Saturation)
For Photoshop (Photography -> Adjustments -> Hue/Saturation)
if value is above 0, use exact value , if value is below 0, take postivie (absolute) of value, add it in 180 and use the result value.
-
There is an ancient tool called GetColor. I still use this today! Check it out. wincatalog.com/getcolor.html – Steven Hammons Jul 14 '17 at 18:17
Symbol You Want on Color You Want!
I was looking for this answer for days and here it is the right and easy way to create a custom marker:
'http://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=xxx%7c5680FC%7c000000&.png' where xxx is the text and 5680fc is the hexadecimal color code and 000000 is the hexadecimal color code of the text.
Theses markers are totally dynamic and you can create whatever balloon icon you want. Just change the URL.