Steve Chadbourne
Steve Chadbourne

Reputation: 6953

Xamarin Forms map pin clicked not working?

I'm using the latest stable version of Xamarin.Forms and Xamarin.Forms.Maps (v1.3.1.6296) on iOS.

I created a new pin, added a Clicked event handler and added the pin to the map.

I put a breakpoint in the Pin_Clicked event handler but it does not get called when I click the pin popup.

I also tried the latest pre-release (1.3.2.6299-pre1) but no change.

Any ideas?

Here is the code

using Xamarin.Forms;
using Xamarin.Forms.Maps;

namespace Kern.Client.Views
{
    public class MapView : ContentPage
    {
        public MapView()
        {
            SetupView();
        }

        private void SetupView()
        {
            MapSpan mapSpan = MapSpan.FromCenterAndRadius(new Position(-36.740737, 174.702464), Distance.FromKilometers(1));

            var map = new Map(mapSpan)
            {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var pin = new Pin
            {
                Type = PinType.Place,
                Position = new Position(-36.742315, 174.698151),
                Label = "Title",
                Address = "Address",
            };

            pin.Clicked += (sender, args) => DisplayAlert("Tapped!", "Pin was tapped.", "OK");

            map.Pins.Add(pin);

            Content = map;
        }

    }
}

Upvotes: 0

Views: 2502

Answers (2)

Prashant Cholachagudda
Prashant Cholachagudda

Reputation: 13092

It is a bug in Xamarin.Forms 1.3.1, I believe it is not fixed in v1.3.2-pre1 yet.

Upvotes: 3

Kolchy
Kolchy

Reputation: 85

This works for me:

pin.Clicked += (sender, args) => {
    DisplayAlert ("Tapped!", "Pin was tapped.", "OK");
};

Upvotes: 1

Related Questions