简体   繁体   English

在Pin Map控件Xamarin表单pcl上调用click事件

[英]call the click event on the Pin Map control Xamarin forms pcl

I'm looking online but could not find anything, I'm using the Map control Xamarin forms pcl. 我在网上寻找,但找不到任何东西,我在使用地图控件Xamarin表单pcl。 And I must say that I find the event to trigger when I click on the Pin on the map (google maps). 而且我必须说,我单击地图上的Pin(谷歌地图)时发现要触发的事件。 Can anyone advise me? 谁能告诉我? thank you. 谢谢。

var map = new Map(
                    MapSpan.FromCenterAndRadius(
                        new Position(lat, lon), Distance.FromMiles(50)))
                    {
                        IsShowingUser = true,
                        HeightRequest = CrossScreen.Current.Size.Height,
                        WidthRequest = CrossScreen.Current.Size.Width,
                        VerticalOptions = LayoutOptions.FillAndExpand
                    };

                    RGL_Locations = RGL_Locations.OrderByDescending(x => x.RGL_DateTime).ToList();

                    foreach (RGL_Locations item in RGL_Locations)
                    {
                        map.Pins.Add(new Pin { Type = PinType.Generic, Label = item.RGL_MCC_Numero_Serie_MS.ToString(), Position = new Position(item.RGL_Latitudine, item.RGL_Longitudine) });
                    }

                    map.Pins.Add(new Pin { Type = PinType.Generic, Label = "Io sono qui!", Position = new Position(lat, lon)});

                    var stack = new StackLayout { Spacing = 0 };
                    stack.Children.Add(map);
                    Content = stack;

SOLUTION: 解:

foreach (RGL_Locations item in RGL_Locations)
                    {
                        var pin = new Pin
                        {   
                            Type = PinType.Place,
                            Position = new Position(item.RGL_Latitudine, item.RGL_Longitudine),
                            Label = "Clicca qui per aprire",
                            Address = "Numero di serie macchina: " + item.RGL_MCC_Numero_Serie_MS.ToString()
                        };

                        pin.Clicked += Pin_Clicked;

                        map.Pins.Add(pin);                        
                    }

The Xamarin.Forms.Map Pin class has a Clicked event: Xamarin.Forms.Map Pin类具有Clicked事件:

var position = new Position(32, -13); 
var pin = new Pin
{
    Type = PinType.Place,
    Position = position,
    Label = "custom pin",
    Address = "custom detail info"
};
pin.Clicked +=  (object sender, EventArgs e) =>
{
    var p = sender as Pin;
};

ref: Xamarin.Forms.Maps.Pin.Clicked 参考: Xamarin.Forms.Maps.Pin.Clicked

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM