Add a listener to Pin Clicked into map

Liuk88Liuk88 ITMember ✭✭

Hello guys, I'm trying to add a simple listener like this:

pin.Clicked += (sender, e) =>
{
DisplayAlert("Clicked", "Clicked!", "ok");
};

but seems not working..I found many posts saying the "Clicked" event it's still bugged and I really need one way to add a listener to it..
Someone know how to fix/workaround this problem?
Many thanks

Tagged:

Answers

  • seanydaseanyda GBMember ✭✭✭✭✭

    I've just tested it and it seems to work fine for me.

    test.Clicked += (sender, e) => {
                        DisplayAlert("Test", "Test", "test");
                    };
    
  • Liuk88Liuk88 ITMember ✭✭

    Hi seanyda, already tried but it just show the pin label and not firing at all the DisplayAlert..
    I'm using a PCL project with Xamarin Forms/Maps v.2.4.0.18342
    The code is like this:

    var pin = new Pin
            {
                Type = PinType.Place,
                Position = new Position(44.414615, 8.948675),
                Label = "Text",
                Address = "Details"
            };
    
            pin.Clicked += (sender, e) => {
                DisplayAlert("Test", "Test", "test");
            };
    
            map.Pins.Add(pin);
    
  • seanydaseanyda GBMember ✭✭✭✭✭

    @Liuk88 said:
    Hi seanyda, already tried but it just show the pin label and not firing at all the DisplayAlert..
    I'm using a PCL project with Xamarin Forms/Maps v.2.4.0.18342
    The code is like this:

    var pin = new Pin
    {
    Type = PinType.Place,
    Position = new Position(44.414615, 8.948675),
    Label = "Text",
    Address = "Details"
    };

            pin.Clicked += (sender, e) => {
                DisplayAlert("Test", "Test", "test");
            };
    
            map.Pins.Add(pin);
    

    Definitely working my end. The versions I'm using are:
    Xamarin.Forms.Maps 2.4.0.18342
    Xamarin.Forms 2.5.0.19271-pre2

    Also note I'm testing this on iOS, It may not be working for Android?? also I didn't but it might be worth trying to await the call instead -

    var pin = new Pin
            {
                Type = PinType.Place,
                Position = new Position(44.414615, 8.948675),
                Label = "Text",
                Address = "Details"
            };
    
            pin.Clicked += async(sender, e) => {
                await DisplayAlert("Test", "Test", "test");
            };
    
            map.Pins.Add(pin);
    
  • Liuk88Liuk88 ITMember ✭✭

    I just noticed a thing..is working fine but I need to click in the Label message (and not on the marker).
    I was trying all way to trigger this event just clicking the marker (and not the Label message :neutral: ).
    Do you have the same behaviour on IOS? (I'm working in Android). Is not be supposed to react to the MARKER click?

  • seanydaseanyda GBMember ✭✭✭✭✭

    @Liuk88 said:
    I just noticed a thing..is working fine but I need to click in the Label message (and not on the marker).
    I was trying all way to trigger this event just clicking the marker (and not the Label message :neutral: ).
    Do you have the same behaviour on IOS? (I'm working in Android). Is not be supposed to react to the MARKER click?

    Yeah! Just tested and that's the same for iOS. That must be the intended functionality.

  • Liuk88Liuk88 ITMember ✭✭
    edited October 2017

    Damn, I need to override the marker click and not the info window click :(
    I guess there is no way and I'll go to use it in this way..
    BTW thanks :)

Sign In or Register to comment.