我不太明白为什么这不起作用:( Bing映射Silverlight控件WP7)
在此处添加图钉:
GeoCoordinate location = new GeoCoordinate();
location.Latitude = 51.5;
location.Longitude = 0;
pushpin1.Location = location;
map1.Children.Add(pushpin1);
在此处删除图钉:
map1.Children.Remove(pushpin1);
这不会移除图钉,我做错了什么?
感谢。
答案 0 :(得分:4)
我使用以下代码:
private void AddPushpinButton_Click(object sender, RoutedEventArgs e)
{
GeoCoordinate location = new GeoCoordinate() { Latitude = 51.5, Longitude = 0 };
Pushpin pushpin1 = new Pushpin() { Location = location, Tag = "FindMeLater" };
map1.Children.Add(pushpin1);
}
private void RemovePushpinButton_Click(object sender, RoutedEventArgs e)
{
var pushpin = map1.Children.First(p => (p.GetType() == typeof(Pushpin) && ((Pushpin)p).Tag == "FindMeLater"));
map1.Children.Remove(pushpin);
}