<?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 Need some OnClick clarification in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-some-onclick-clarification/m-p/231643#M21616</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm building a small app that has a basemap and one featureLayer that has an infoWindow associated with it. When the user clicks on one of those features, I also need to retrieve the coordinates of the feature that the user clicked on. My understanding is that you can use the OnClick event with dojo.connect to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.connect(map,"onClick",function(evt){ &amp;nbsp;&amp;nbsp; var query = new esri.tasks.Query(); &amp;nbsp;&amp;nbsp; query.geometry = pointToExtent(map,evt.mapPoint,10);&amp;nbsp; &amp;nbsp;&amp;nbsp; var deferred = theFeatureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);&amp;nbsp; &amp;nbsp;&amp;nbsp; map.infoWindow.setFeatures([deferred]); &amp;nbsp;&amp;nbsp; map.infoWindow.show(evt.mapPoint);&amp;nbsp; &amp;nbsp;&amp;nbsp; alert('Made it here!'); &amp;nbsp;&amp;nbsp; var pt = new esri.geometry.Point(evt.mapPoint.y,evt.mapPoint.x, new esri.SpatialReference({wkid:3857})); &amp;nbsp;&amp;nbsp; var MercPt = esri.geometry.webMercatorToGeographic(evt.mapPoint); &amp;nbsp;&amp;nbsp; var theLong = MercPt.x; &amp;nbsp;&amp;nbsp; var theLat = MercPt.y; &amp;nbsp;&amp;nbsp; var didSucceed = window.clipboardData.setData('Text', '@Coord:' + theLong.toString() + ',' + theLat.toString() ); &amp;nbsp; });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If a user clicks on the map where there isn't a feature, the OnClick event captures it and I'm able to access the click point's coordinates. If they click on a feature, it seems to bypass the OnClick code (hence my small alert line in the code above). What's the best way to capture the coordinates of a clicked feature??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 May 2012 19:34:32 GMT</pubDate>
    <dc:creator>SteveCole</dc:creator>
    <dc:date>2012-05-21T19:34:32Z</dc:date>
    <item>
      <title>Need some OnClick clarification</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-some-onclick-clarification/m-p/231643#M21616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm building a small app that has a basemap and one featureLayer that has an infoWindow associated with it. When the user clicks on one of those features, I also need to retrieve the coordinates of the feature that the user clicked on. My understanding is that you can use the OnClick event with dojo.connect to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.connect(map,"onClick",function(evt){ &amp;nbsp;&amp;nbsp; var query = new esri.tasks.Query(); &amp;nbsp;&amp;nbsp; query.geometry = pointToExtent(map,evt.mapPoint,10);&amp;nbsp; &amp;nbsp;&amp;nbsp; var deferred = theFeatureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);&amp;nbsp; &amp;nbsp;&amp;nbsp; map.infoWindow.setFeatures([deferred]); &amp;nbsp;&amp;nbsp; map.infoWindow.show(evt.mapPoint);&amp;nbsp; &amp;nbsp;&amp;nbsp; alert('Made it here!'); &amp;nbsp;&amp;nbsp; var pt = new esri.geometry.Point(evt.mapPoint.y,evt.mapPoint.x, new esri.SpatialReference({wkid:3857})); &amp;nbsp;&amp;nbsp; var MercPt = esri.geometry.webMercatorToGeographic(evt.mapPoint); &amp;nbsp;&amp;nbsp; var theLong = MercPt.x; &amp;nbsp;&amp;nbsp; var theLat = MercPt.y; &amp;nbsp;&amp;nbsp; var didSucceed = window.clipboardData.setData('Text', '@Coord:' + theLong.toString() + ',' + theLat.toString() ); &amp;nbsp; });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If a user clicks on the map where there isn't a feature, the OnClick event captures it and I'm able to access the click point's coordinates. If they click on a feature, it seems to bypass the OnClick code (hence my small alert line in the code above). What's the best way to capture the coordinates of a clicked feature??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2012 19:34:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-some-onclick-clarification/m-p/231643#M21616</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2012-05-21T19:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need some OnMouseDown clarification</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-some-onclick-clarification/m-p/231644#M21617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'll give a stab at it- &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your dojo event handler is pointing to the map, not the feature layer. Do something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;dojo.connect(featurelayer, "onClick", function(evt){&amp;nbsp; console.log(evt)&amp;nbsp; })&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if this works.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2012 19:43:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-some-onclick-clarification/m-p/231644#M21617</guid>
      <dc:creator>AR</dc:creator>
      <dc:date>2012-05-21T19:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need some OnClick clarification</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-some-onclick-clarification/m-p/231645#M21618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;GENIUS!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I feel so dumb. Thanks- that was the problem!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2012 19:55:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-some-onclick-clarification/m-p/231645#M21618</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2012-05-21T19:55:54Z</dc:date>
    </item>
  </channel>
</rss>

