private object RequestResponder(OperationType type, object param = null) { switch (type) { case OperationType.SentStyleGalleryItem: m_pStyleGalleryItem = param as IStyleGalleryItem; return(null); case OperationType.GetViewIndex: return(Ctrl_Tab.SelectedIndex); case OperationType.GetSelectedLayer: return(m_selectedLayer); case OperationType.RefreshMapCtrl: Ctrl_Map.Refresh(); return(null); case OperationType.UpdateTOCCtrl: Ctrl_TOC.Update(); return(null); case OperationType.ClearSelection: Ctrl_Map.Map.ClearSelection(); return(null); case OperationType.ModifyExtent: Ctrl_Map.Extent = param as IEnvelope; return(null); case OperationType.GetMap: return(Ctrl_Map.Map); case OperationType.GetScene: return(Ctrl_Scene.Scene); case OperationType.ZoomToSelection: ICommand curCmd = new ControlsZoomToSelectedCommandClass(); curCmd.OnCreate(Ctrl_Map.Object); curCmd.OnClick(); return(null); case OperationType.FormAttributeHighLightRow: if (m_FrmAttribute != null) { m_FrmAttribute.HightLightSelection(); } return(null); default: return(null); } }
private void ZoomToSelectedFeatures() { try { ICommand pZoomToSelectedFeaturesCommand = new ControlsZoomToSelectedCommandClass(); pZoomToSelectedFeaturesCommand.OnCreate(m_MapControl.Object); pZoomToSelectedFeaturesCommand.OnClick(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//buffer查询并闪烁。 public static void BufferSelectAndFlash(IMapControl4 mapCtrl, IGeometry baseGeo, esriSpatialRelEnum spatialRef, ILayer layer) { IFeatureLayer featureLayer = layer as IFeatureLayer; if (mapCtrl == null || featureLayer == null) { return; } IFeatureClass fC = featureLayer.FeatureClass; ISpatialFilter pFilter = new SpatialFilterClass(); pFilter.Geometry = baseGeo; pFilter.GeometryField = "SHAPE"; pFilter.SpatialRel = spatialRef; IFeatureCursor pFeatureCursor = fC.Search(pFilter, false); IArray inArray = new ArrayClass(); IFeature fe = pFeatureCursor.NextFeature(); mapCtrl.Map.ClearSelection(); while (fe != null) { inArray.Add(fe); mapCtrl.Map.SelectFeature(layer, fe); fe = pFeatureCursor.NextFeature(); } if (inArray == null) { return; } HookHelper m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = mapCtrl.Object; IHookActions hookAction = (IHookActions)m_hookHelper; ICommand cmd = new ControlsZoomToSelectedCommandClass(); cmd.OnCreate(m_hookHelper.Hook); cmd.OnClick(); Application.DoEvents(); hookAction.DoActionOnMultiple(inArray, esriHookActions.esriHookActionsFlash); }
void IGMap.ZoomToSelected() { ICommand command = new ControlsZoomToSelectedCommandClass(); command.OnCreate(this._hook); command.OnClick(); }
/// <summary> /// 地图定位方法 /// </summary> /// <param name="layerNames">图层名称</param> /// <param name="pColumnContent">要定位网元的名称内容</param> public bool Locate(string layerNames, string pColumnContent) { IFeatureLayer pFeatureLayer = null; string ColumnName = null;//图层中小区对应的名称 string columnLON = null; string columnLAT = null; switch (layerNames) { case LayerNames.GSM900Cell: { pFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.GSM900Cell) as IFeatureLayer; ColumnName = "cellname"; columnLON = "longitude"; columnLAT = "latitude"; break; } case LayerNames.GSM1800Cell: { pFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.GSM1800Cell) as IFeatureLayer; ColumnName = "cellname"; columnLON = "longitude"; columnLAT = "latitude"; break; } } if (pFeatureLayer == null) { return(false); } IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = ColumnName + "='" + pColumnContent + "'"; IFeatureCursor pFCursor = pFeatureClass.Search(queryFilter, false); IFeature pFeature = pFCursor.NextFeature(); while (pFeature != null) { int indexOfName = pFeatureClass.FindField(ColumnName); int indexLon = pFeatureClass.FindField(columnLON); int indexLat = pFeatureClass.FindField(columnLAT); if (pFeature.get_Value(indexOfName).ToString() == pColumnContent) { //定位到查询的图元 double lon = Convert.ToDouble(pFeature.get_Value(indexLon)); double lat = Convert.ToDouble(pFeature.get_Value(indexLat)); ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass(); pSelectionEnv.CombinationMethod = ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew; if (pFeatureLayer.Selectable == true) { GISMapApplication.Instance.Scene.ClearSelection(); ICommand pCommand = new ControlsZoomToSelectedCommandClass(); //Select by Shape IPoint pNewCenterPoint = new PointClass(); pNewCenterPoint.X = lon; pNewCenterPoint.Y = lat; PointConvert.Instance.GetProjectPoint(pNewCenterPoint); pSelectionEnv.DefaultColor = GISUtil.GetRGB(255, 0, 0); // 定位居中 ILayer referLayer = GISMapApplication.Instance.GetLayer("建筑物");//定位居中参照图层。 IEnvelope pEnvelope = referLayer.AreaOfInterest; //IEnvelope pEnvelope = pFeatureLayer.AreaOfInterest; pEnvelope.CenterAt(pNewCenterPoint); pEnvelope.Expand(0.1, 0.1, true); GISMapApplication.Instance.FullExtent(pEnvelope); //GISMapApplication.Instance.Scene.ClearSelection(); //GISMapApplication.Instance.Scene.SelectByShape(pFeature.Shape, pSelectionEnv, true); GISMapApplication.Instance.Scene.SelectFeature(pFeatureLayer, pFeature); HandlerFeatureData(layerNames, pFeature); return(true); } } } return(false); }
private void zoomtofeature_Click(object sender, EventArgs e) { IMap imap = axMapControl1.Map; ICommand pCommand = new ControlsZoomToSelectedCommandClass(); pCommand.OnCreate(axMapControl1.Object); pCommand.OnClick(); }