AnsweredAssumed Answered

Java Identifying Clicked Feature

Question asked by rohneas on Aug 13, 2012
Latest reply on Aug 14, 2012 by rohneas
I am trying to identify the feature a user clicks on.  This would be similar to the identify tool, but instead of showing a window, I want to take some of the feature attributes and put them into another table.

The problem I'm having is that every way I try to identify the feature that was clicked on, I get a null result.  The code I'm using is below:

for(int x=0;x<focusMap.getLayerCount();x++){  if(focusMap.getLayer(x).getName().equals("Origin Locations")){   FeatureLayer featLayer=(FeatureLayer) focusMap.getLayer(x);   IIdentify ident=featLayer;   IPoint point=new Point();   point=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX(), me.getY());  /*  * The point object has the correct geographic coordinates at this point, so I'm thinking it is not the issue (and at  *   one point, I thought that was the issue because I was passing screen coordinates to the identify commands  *   below).  */        IArray result=ident.identify(point);    IArray result2=featLayer.identify(point,null);    IArray result3=featLayer.identify(point); /*  * The result, result2, and result3 objects (above) are all null here.  I've tried passing an IGeometry object to these  *   commands as well, and that was to no avail.  */   if(result!=null){    for(int i=0;i<result.getCount();i++){     System.out.println(result.getElement(i).toString());    }   }  } }


If anyone can get me pointed in the right direction here, I would appreciate it!

Andrew Rohne
OKI Regional Council

Outcomes