How I can in arcgis Engine get the object on wich I click ?How I can get X,Y coordinates of that object (using shape field?)?Thanks for any advice or reference!
private ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler m_ActiveViewEventsSelectionChanged; m_map = (ESRI.ArcGIS.Carto.IMap)axMapControl1.ActiveView.FocusMap; // Explict Cast //Create an instance of the delegate, add it to SelectionChanged event m_ActiveViewEventsSelectionChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler(OnActiveViewEventsSelectionChanged); ((ESRI.ArcGIS.Carto.IActiveViewEvents_Event)(m_map)).SelectionChanged += m_ActiveViewEventsSelectionChanged; private void OnActiveViewEventsSelectionChanged() { // Сode here }
private void OnActiveViewEventsSelectionChanged() { ICompositeLayer layer1; IFeatureLayer layer; layer1 = axMapControl1.get_Layer(2) as ESRI.ArcGIS.Carto.ICompositeLayer; layer = layer1.get_Layer(0) as ESRI.ArcGIS.Carto.IFeatureLayer; IBasicMap map = null; ILayer layer2 = null; layer.Selectable = true; Object other = null; Object index = null; esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.GetSelectedItem(ref item, ref map, ref layer2, ref other, ref index); IGeoFeatureLayer player; player = layer2 as IGeoFeatureLayer; player.Selectable = true; ESRI.ArcGIS.Geodatabase.IFeatureClass pFc;// = player as ESRI.ArcGIS.Geodatabase.IFeatureClass; string strOIDName; pFc = player.FeatureClass; if(pFc!=null) strOIDName = pFc.OIDFieldName; ESRI.ArcGIS.Carto.IFeatureSelection pFSel; pFSel = player as ESRI.ArcGIS.Carto.IFeatureSelection; ESRI.ArcGIS.Geodatabase.ISelectionSet pSelSet; pSelSet = pFSel.SelectionSet; ESRI.ArcGIS.Geodatabase.ICursor pFCur; pSelSet.Search(null, false, out pFCur); int nlay = pFCur.FindField("Centr_lesn"); string centr = pFCur.NextRow().get_Value(nlay).ToString(); this.label2.Text = centr; IFeatureSelection featureSelection = layer2 as IFeatureSelection; ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet = featureSelection.SelectionSet; }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.