我的代码
public void BuildMapLine(List<Location> locations)
{
MapLayer mapLayer = new MapLayer();
mapLayer.Children.Clear();
MapPolyline polyline = new MapPolyline();
polyline.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
polyline.StrokeThickness = 5;
polyline.Opacity = 0.7;
polyline.ToolTip = Hurricane;
polyline.Locations = new LocationCollection();
foreach(var item in locations)
{
polyline.Locations.Add(item);
}
mapLayer.AddChild(polyline, polyline.Locations); //error , cant take in a list of locations
mWindow.myMap.Children.Add(mapLayer);
}
问题是我似乎无法将折线添加到地图图层,我希望它可以在地图图层中与要添加到地图上的图钉分开删除
我该怎么做?