/// <summary> /// 删除图层 /// </summary> /// <param name="map"></param> /// <param name="tree"></param> /// <param name="cmd"></param> private void DeleteLayer(MapImage map, MyTree tree, string[] cmd) { if (cmd.Length != 3) { return; } decimal layerid = GetId(cmd[2]); TreeNode layernode = FindLayer(tree.Nodes[0], layerid); if (layernode == null) { return; } //取得当前图层 VectorLayer layer = layernode.Tag as VectorLayer; if (map.NeedSave && layer.NeedSave) { MapDBClass.DeleteLayer(map.Map.MapId, layer.ID); } //删除选择的图层 map.Map.Layers.Remove(layer); TreeNode parentnode = layernode.Parent; //删除选择的节点 tree.Nodes.Remove(layernode); if (parentnode.Nodes.Count <= 0) { parentnode.Remove(); } foreach (TreeNode node in tree.Nodes[0].Nodes) { if (node.Nodes.Count <= 0) { node.Remove(); } } }