gpt4 book ai didi

c# - 在 Pin Map 控件上调用 click 事件 Xamarin forms pcl

转载 作者:行者123 更新时间:2023-11-30 20:33:06 27 4
gpt4 key购买 nike

我在网上查找但找不到任何内容,我正在使用 map 控件 Xamarin 表单 pcl。我必须说,当我点击 map (谷歌地图)上的 Pin 时,我发现事件会触发。谁能给我建议?谢谢。

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;

解决方案:

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);
}

最佳答案

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;
};

引用:Xamarin.Forms.Maps.Pin.Clicked

关于c# - 在 Pin Map 控件上调用 click 事件 Xamarin forms pcl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40634180/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com