Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using ArcGIS 10.1 and developing an application using visual studio 2010 and ARCObject SDK 10.1.

I would like to use identity tool in my application and if not possible I want to execute a query on the attribute table of the map layer when a user clicks on it.

Any ideas on how I can accomplish this task? From my research,I think IQuery interface may be used; however, I would like to do the query based on a mouse click event.

share|improve this question

closed as unclear what you're asking by Devdatta Tengshe, neogeomat, Curlew, Mapperz Jan 16 '14 at 16:16

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Are you developing a standalone application, or is this within Arcmap? – Kirk Kuykendall May 1 '13 at 13:32
witin arcmap as addin – Nhqazi May 4 '13 at 14:55
do you mean Identify Tool? have you tried it yet? – XtianGIS Dec 16 '13 at 21:21

If I were doing it I would get the XY coordinate of the point clicked using a tool button. Convert these coordinates into a point geometry and feed that into an ISpatialFilter then create a cursor over the FeatureLayer where the point intersects. I've made various assumptions in that statement...

This question is better answered by the ESRI forum as what you are asking is something that developers regularly ask about.

share|improve this answer
i did as u asked me however the return cursor contains all the record rather than a single record. Please look at the code below – Nhqazi May 6 '13 at 21:28

i did as u asked me however the return cursor contains all the record rather than a single record. Please look at the code below Please look the code , I wish to access the feature at the mouse coordinate on mouse click event. however my code below return all the records rather than a single point. any guess what is wrong.

IMxApplication pMxApp = null;
pMxApp = (IMxApplication)ArcMap.Application;
IMxDocument pMxDoc = null;

pMxDoc = ArcMap.Document;
if (pMxDoc.SelectedLayer == null)
    MessageBox.Show("There is no layer selected. First select a time-aware layer.");
IMap pMap = pMxDoc.FocusMap;
IFeatureLayer feature_layer = (IFeatureLayer)pMap.get_Layer(0);
IPoint point = new PointClass();

x = pMxDoc.CurrentLocation.X; 
 y = pMxDoc.CurrentLocation.Y;
MessageBox.Show(x+ ":" + y);
point.PutCoords(x, y);

point.SpatialReference = pMap.SpatialReference;
ISpatialFilter spatial_filter = new SpatialFilterClass();
spatial_filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
spatial_filter.Geometry = point;
 spatial_filter.GeometryField = feature_layer.FeatureClass.ShapeFieldName;
IFeatureCursor feature_cursor = feature_layer.FeatureClass.Search(spatial_filter,        false);
IFeature feature = feature_cursor.NextFeature();

 while (feature != null) // here it returns the whole records rather than single point.

      feature = feature_cursor.NextFeature();

share|improve this answer
You should make sure your code is tagged as code using the {} button, it's difficult to read and interpret this unformatted code – Hornbydd May 6 '13 at 22:13
Please have a look now. thnx – Nhqazi May 7 '13 at 9:15

This snippet is a bit old and in VBA, however I think it should give you the result you are looking for (after converting it to .NET/C# add-in). It basically uses a buffered search point on mouse down event, then uses a spatial filter and search cursor to return the feature.

Find a Feature Programmatically

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.