【发布时间】:2016-11-16 14:06:32
【问题描述】:
我正在网上寻找但找不到任何东西,我正在使用 Map 控件 Xamarin forms pcl。 我必须说,当我点击地图(谷歌地图)上的 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);
}
【问题讨论】:
标签: c# google-maps xamarin xamarin.forms portable-class-library