C# Bing地图无法从地图中删除路线多边形线
我使用以下xaml将类C# Bing地图无法从地图中删除路线多边形线,c#,.net,windows-phone-7,bing-maps,C#,.net,Windows Phone 7,Bing Maps,我使用以下xaml将类LocationCollection的实例绑定到类MapPolyline的实例 <Microsoft_Phone_Controls_Maps:MapPolyline Stroke="Green" Locations="{Binding Points}" StrokeThickness="6"
LocationCollection
的实例绑定到类MapPolyline
的实例
<Microsoft_Phone_Controls_Maps:MapPolyline Stroke="Green"
Locations="{Binding Points}"
StrokeThickness="6"
Opacity="0.7" />
现在,当我设置Points
属性时,路线将按预期显示,但当我想删除带有以下代码的路线时,路线仍会显示-即使我创建了一个新的空LocationCollection
类并通知属性已更改
有人知道为什么路线没有被移除吗
this.Points = new LocationCollection();
答案是将集合设置为新实例或完全清除当前集合是错误的,我要做的是从集合中删除除第一项以外的所有项 e、 g
使用此选项创建管线层
MapLayer route_layer = new MapLayer();
route_layer.Children.Add(routeLine);
MyMap.Children.Add(route_layer);
使用MapPolyline创建线,例如
MapPolyline routeLine = new MapPolyline()
{
Locations = locs,
Stroke = new SolidColorBrush(c),
StrokeThickness = 5
};
添加到管线图层,然后使用此图层进行贴图
MapLayer route_layer = new MapLayer();
route_layer.Children.Add(routeLine);
MyMap.Children.Add(route_layer);
使用此选项从地图中删除
MyMap.Children.Remove(route_layer);