var mv = MapView.Active; var lyrs = mv.Map.Layers; var sb = new StringBuilder(); foreach (var lyr in lyrs) { sb.AppendLine(lyr.Name); } MessageBox.Show(sb.ToString());
删除所有图层
var mv = MapView.Active; var lyrs = mv.Map.Layers; foreach (var lyr in lyrs) { if (lyr == null) break; try { QueuedTask.Run(() => { mv.Map.RemoveLayer(lyr); //lyrs = mv.Map.Layers; }); } catch(Exception ex) { MessageBox.Show(ex.Message); } }
private void openAll() //打开所有图层 { var mv = MapView.Active; var lyrs = mv.Map.Layers; foreach (var lyr in lyrs) { if (!lyr.IsVisible) { QueuedTask.Run(() => { lyr.SetVisibility(true); }); } } } private void CloseAll() //关闭所有图层 { var mv = MapView.Active; var lyrs = mv.Map.Layers; foreach (var lyr in lyrs) { if (lyr.IsVisible) { QueuedTask.Run(() => { lyr.SetVisibility(false); }); } } }