public void SelectByPolygons(IFeatureLayer selectedItem) { IFeatureLayer baseLayer = selectedItem; IFeatureLayer selectLayer = null; foreach (ILayer layer in _map.MapFrame.DrawingLayers) { if (layer.LegendText == "Polygon") { selectLayer = layer as IFeatureLayer; break; } } List <int> resultIndices = null; if (selectLayer != null) { QueryCommand query = new QueryCommand(); resultIndices = query.SpatialFilter(baseLayer.DataSet, selectLayer.DataSet); } if (resultIndices != null) { baseLayer.UnSelectAll(); baseLayer.Select(resultIndices); _map.Refresh(); } }
//作为委托传入到DrawPolygon操作中 public void SelectByPolygon(IFeatureLayer drawedLayer) { ILegendItem selectedItem = (GIS.FrameWork.Application.App.Legend as GIS.Common.Dialogs.Legend).SelectedLegendMenuItem; if (selectedItem != null && selectedItem is IFeatureLayer) { IFeatureLayer baseLayer = selectedItem as IFeatureLayer; IFeatureLayer selectLayer = drawedLayer; List <int> resultIndices = null; if (selectLayer != null) { QueryCommand query = new QueryCommand(); resultIndices = query.SpatialFilter(baseLayer.DataSet, selectLayer.DataSet); } if (resultIndices != null) { baseLayer.UnSelectAll(); baseLayer.Select(resultIndices); _map.Refresh(); } } }