amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 346 forks source link

[Question] Show specific pin #634

Closed AnthonyLatty closed 5 years ago

AnthonyLatty commented 5 years ago

I was wondering if it is possible to display a specific pin when its clicked. For example: When all the pins are loaded can i have a DisplayAlert attached to a specific pin? that way when that pin is clicked it will show it only for that particular pin?

amay077 commented 5 years ago

Sorry I can not understand you want.

Xamarin.Forms.GoogleMaps has Pin.IsVisible property. This means, You can control to Pin show/hide.

AnthonyLatty commented 5 years ago

No Pin.IsVisible is not what i want.

What i would like to know is if the library supports clicking on a particular pin and raising an event for that pin. For example if i have 3 Pins being shown on a map, i would like the user to click on the first pin and that pin raises an event. If the user clicks on the Second Pin that should raise a different event.

amay077 commented 5 years ago

You can use Map.PinClicked event.

map.PinClicked += (sender, e) =>
{
    if (Object.ReferenceEquals(e.Pin, pin1))
    {
        Debug.WriteLine("you clicked pin1");
    }
    else if (Object.ReferenceEquals(e.Pin, pin2))
    {
        Debug.WriteLine("you clicked pin2");
    }
    else if (Object.ReferenceEquals(e.Pin, pin3))
    {
        Debug.WriteLine("you clicked pin3");
    }
}
AnthonyLatty commented 5 years ago

Works as expected..