Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] c# – How to add overlay color on the BitmapDescriptor for Android project in Xamarin Forms Maps

Posted on November 14, 2022

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?

READ  [ANSWERED] java - Finding Files in Directory With Specific Letters
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress