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()); } } } }
Solved! Go to Solution.
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; IEnvelope envelope = new Envelope(); IPoint envLL=new Point(); IPoint envUR=new Point(); envLL=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()-5, me.getY()+7); envUR=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()+5, me.getY()-7); envelope.setLowerLeft(envLL); envelope.setUpperRight(envUR); IArray result=ident.identify(envelope); if(result!=null){ for(int i=0;i<result.getCount();i++){ System.out.println(result.getElement(i).toString()); } } } }
Also, I dont' think that code will work if you have to change the projection of your data frame to WGS coordinates. +/- 5 in WGS will probably not give you what you expect. Does it?
Change your zoom level with the code you have. Does it catch the feature you want to identify?
envLL=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()-5, me.getY()+7);