<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Java Identifying Clicked Feature in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88113#M2306</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Also, I dont' think that code will work if you have to change the projection of your data frame to WGS coordinates.&amp;nbsp; +/- 5 in WGS will probably not give you what you expect.&amp;nbsp; Does it?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Since he's adding and subtracting from screen coordinates (before the toMapPoint transformation), the type of coordinate system shouldn't matter, right? I think that's the best way to do it; it should work as expected regardless of zoom level or of coordinate system.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Aug 2012 12:01:11 GMT</pubDate>
    <dc:creator>EricWeber</dc:creator>
    <dc:date>2012-08-14T12:01:11Z</dc:date>
    <item>
      <title>Java Identifying Clicked Feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88108#M2301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to identify the feature a user clicks on.&amp;nbsp; 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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem I'm having is that every way I try to identify the feature that was clicked on, I get a null result.&amp;nbsp; The code I'm using is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for(int x=0;x&amp;lt;focusMap.getLayerCount();x++){&amp;nbsp; if(focusMap.getLayer(x).getName().equals("Origin Locations")){ &amp;nbsp; FeatureLayer featLayer=(FeatureLayer) focusMap.getLayer(x); &amp;nbsp; IIdentify ident=featLayer; &amp;nbsp; IPoint point=new Point(); &amp;nbsp; point=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX(), me.getY());&amp;nbsp; /*&amp;nbsp; * The point object has the correct geographic coordinates at this point, so I'm thinking it is not the issue (and at&amp;nbsp; *&amp;nbsp;&amp;nbsp; one point, I thought that was the issue because I was passing screen coordinates to the identify commands&amp;nbsp; *&amp;nbsp;&amp;nbsp; below).&amp;nbsp; */&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; IArray result=ident.identify(point);&amp;nbsp; &amp;nbsp; IArray result2=featLayer.identify(point,null);&amp;nbsp; &amp;nbsp; IArray result3=featLayer.identify(point); /*&amp;nbsp; * The result, result2, and result3 objects (above) are all null here.&amp;nbsp; I've tried passing an IGeometry object to these&amp;nbsp; *&amp;nbsp;&amp;nbsp; commands as well, and that was to no avail.&amp;nbsp; */ &amp;nbsp; if(result!=null){ &amp;nbsp;&amp;nbsp; for(int i=0;i&amp;lt;result.getCount();i++){ &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(result.getElement(i).toString()); &amp;nbsp;&amp;nbsp; } &amp;nbsp; }&amp;nbsp; } }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If anyone can get me pointed in the right direction here, I would appreciate it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew Rohne&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;OKI Regional Council&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 14:03:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88108#M2301</guid>
      <dc:creator>AndrewRohne</dc:creator>
      <dc:date>2012-08-13T14:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Java Identifying Clicked Feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88109#M2302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rather than passing the point to the Identify method, you'll probably want to pass a small envelope or circle (centered on the click point) to tolerate the click being a slight distance from the feature. What type of features are you identifying? Polygons, lines, points? If points or lines, then passing a small envelope could be your solution. If you're working with polygons and a click right in the center is still resulting in a null array, there must be some other problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 19:02:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88109#M2302</guid>
      <dc:creator>EricWeber</dc:creator>
      <dc:date>2012-08-13T19:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Java Identifying Clicked Feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88110#M2303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks!&amp;nbsp; That's what I needed.&amp;nbsp; Based on some tests I did, it appears that if you pass it a point object, you have to have the &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;EXACT POINT&lt;/SPAN&gt;&lt;SPAN&gt; or it will fail.&amp;nbsp; Passing it an envelope worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For the sake of anyone finding this later on, here is the code I'm using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for(int x=0;x&amp;lt;focusMap.getLayerCount();x++){
 if(focusMap.getLayer(x).getName().equals("Origin Locations")){ 
&amp;nbsp; FeatureLayer featLayer=(FeatureLayer) focusMap.getLayer(x);
&amp;nbsp; IIdentify ident=featLayer;
&amp;nbsp; IEnvelope envelope = new Envelope();
&amp;nbsp; IPoint envLL=new Point();
&amp;nbsp; IPoint envUR=new Point();
&amp;nbsp; envLL=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()-5, me.getY()+7);
&amp;nbsp; envUR=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()+5, me.getY()-7);
&amp;nbsp; envelope.setLowerLeft(envLL);
&amp;nbsp; envelope.setUpperRight(envUR);
&amp;nbsp; IArray result=ident.identify(envelope);
&amp;nbsp; if(result!=null){
&amp;nbsp;&amp;nbsp; for(int i=0;i&amp;lt;result.getCount();i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(result.getElement(i).toString());
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
 }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I based the envelope on the screen coordinates and converted them to geographic coordinates for the points for the envelope upper-right and lower-left corners of the envelope.&amp;nbsp; This hopefully will serve me well at different zoom levels.&amp;nbsp; The X +/- 5 and Y+/- 7 works for me, but others may want to run a few tests to see if their mileage varies.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:21:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88110#M2303</guid>
      <dc:creator>AndrewRohne</dc:creator>
      <dc:date>2021-12-10T23:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Java Identifying Clicked Feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88111#M2304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Andrew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change your zoom level with the code you have.&amp;nbsp; Does it catch the feature you want to identify?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:27:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88111#M2304</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-08-13T20:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Java Identifying Clicked Feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88112#M2305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, I dont' think that code will work if you have to change the projection of your data frame to WGS coordinates.&amp;nbsp; +/- 5 in WGS will probably not give you what you expect.&amp;nbsp; Does it?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:30:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88112#M2305</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-08-13T20:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Java Identifying Clicked Feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88113#M2306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Also, I dont' think that code will work if you have to change the projection of your data frame to WGS coordinates.&amp;nbsp; +/- 5 in WGS will probably not give you what you expect.&amp;nbsp; Does it?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Since he's adding and subtracting from screen coordinates (before the toMapPoint transformation), the type of coordinate system shouldn't matter, right? I think that's the best way to do it; it should work as expected regardless of zoom level or of coordinate system.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 12:01:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88113#M2306</guid>
      <dc:creator>EricWeber</dc:creator>
      <dc:date>2012-08-14T12:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Java Identifying Clicked Feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88114#M2307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Change your zoom level with the code you have.&amp;nbsp; Does it catch the feature you want to identify?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It does!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
envLL=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()-5, me.getY()+7);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the above, me.getX() and me.getY() are screen coordinates.&amp;nbsp; They are independent of zoom.&amp;nbsp; The .toMapPoint(x,y) function changes those screen coordinates to geographic coordinates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To answer your other question, I haven't tried geographic coordinates or any projection other than NAD83 State Plane Ohio South.&amp;nbsp; I THINK (operative word!) that it would still work the same way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:22:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/java-identifying-clicked-feature/m-p/88114#M2307</guid>
      <dc:creator>AndrewRohne</dc:creator>
      <dc:date>2021-12-10T23:22:01Z</dc:date>
    </item>
  </channel>
</rss>

