Display locations based on KML file in Bing Windows Phone 7

故事扮演 提交于 2019-12-22 00:50:34

问题


Currently i am using the following code to display locations on a map in my application:

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

This is very tedious as there are hundreds of locations to add, so I was thinking about displaying locations based on a KML file.

My question is how do I display pushpins based on a KML file in windows phone 7 Bing Maps?

Also, I would like to know if there is a way of having an Onclick event for each of these pushpins from the KML file.

Currently I am using the below code which works file, but I 'm not sure how I would implemented that with KML based pushpins

void BusStop8679_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{

    int id = 8679;
    NavigationService.Navigate(new Uri("/DepartureBoard.xaml?ListingId=" + id, UriKind.Relative));           
}

回答1:


Parse the coordinates in the KML file (using RestSharp or a XML de-serializer would make it very easy), then use databinding to bind the coordinate list to the view, and use a ItemTemplate to customize the pushpin itself.

You can then attach a event listener for the Tap event. Set the Tag property to {Binding} , and read it out in the Tap element, and then you can access the element you clicked.



来源:https://stackoverflow.com/questions/7451332/display-locations-based-on-kml-file-in-bing-windows-phone-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!