Solution 1 :
There is currently no way to set the pin color in Xamarin.Forms.Maps.But you could do like below to change the color of your custom pin.
protected override MarkerOptions CreateMarker(Pin pin)
{
CustomPin customPin = (CustomPin)pin;
var marker = new MarkerOptions();
marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
marker.SetTitle(pin.Label);
marker.SetSnippet(pin.Address);
Color color = Color.FromHex("#34ee16");
float hue = color.ToAndroid().GetHue() % 360.0f;
marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(hue));
return marker;
}
Problem :
So, I implemented custom renderer for Android regarding XF Maps, everything is ok, and now I want to add overlay for my pin.
protected override MarkerOptions CreateMarker(Pin pin)
{
CustomPin customPin = (CustomPin)pin;
var marker = new MarkerOptions();
marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
marker.SetTitle(pin.Label);
marker.SetSnippet(pin.Address);
marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));
return marker;
}
How to add an overlay color on pin image? for example Color.FromHex("#34ee16")
Comments
Comment posted by Stefan
So, you want to color your pin?
Comment posted by Stefan0309
@Stefan exactly. Just to put color overlay above my image that represents the pin.
Comment posted by Leo Zhu – MSFT
Do you mean you want to change the pin color ?
Comment posted by Stefan0309
@LeoZhu-MSFT yes. I saw there is an option to put Overlay over Bitmap?