C# 根据Bing Windows Phone 7中的KML文件显示位置
目前,我正在使用以下代码在我的应用程序中显示地图上的位置:C# 根据Bing Windows Phone 7中的KML文件显示位置,c#,silverlight,windows-phone-7,bing-maps,kml,C#,Silverlight,Windows Phone 7,Bing Maps,Kml,目前,我正在使用以下代码在我的应用程序中显示地图上的位置: //Bustop 8448 – Pushpin BusStop8448 = new Pushpin(); BusStop8448.Background = new SolidColorBrush(Colors.Red); BusStop8448.Location = new GeoCoordinate(-36.934608, 174.73016); BusStop8448.Content =
//Bustop 8448 –
Pushpin BusStop8448 = new Pushpin();
BusStop8448.Background = new SolidColorBrush(Colors.Red);
BusStop8448.Location = new GeoCoordinate(-36.934608, 174.73016);
BusStop8448.Content = "Bus Stop: 8448 ";
BusStop8448.MouseLeftButtonUp += new MouseButtonEventHandler(BusStop8448_MouseLeftButtonUp);
var BusStop8448Press = sender as Pushpin;
this.Map.Children.Add(BusStop8448);
这是非常乏味的,因为要添加数百个位置,所以我考虑基于KML文件显示位置
我的问题是如何在WindowsPhone7Bing地图中基于KML文件显示图钉
另外,我想知道是否有一种方法可以为KML文件中的每个图钉都创建Onclick事件
目前我正在使用下面的代码,它可以在文件中工作,但我不确定如何使用基于KML的图钉实现它
void BusStop8679_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
int id = 8679;
NavigationService.Navigate(new Uri("/DepartureBoard.xaml?ListingId=" + id, UriKind.Relative));
}
解析KML文件中的坐标(使用XML或XML反序列化程序将使其非常容易),然后使用将坐标列表绑定到视图,并使用自定义图钉本身 然后,可以为附加事件侦听器。将
标记
属性设置为{Binding}
,并在Tap元素中读取它,然后可以访问单击的元素