AnsweredAssumed Answered

Need some OnClick clarification

Question asked by evtguy on May 21, 2012
Latest reply on May 21, 2012 by evtguy
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:

       dojo.connect(map,"onClick",function(evt){    var query = new esri.tasks.Query();    query.geometry = pointToExtent(map,evt.mapPoint,10);     var deferred = theFeatureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);     map.infoWindow.setFeatures([deferred]);;     alert('Made it here!');    var pt = new esri.geometry.Point(evt.mapPoint.y,evt.mapPoint.x, new esri.SpatialReference({wkid:3857}));    var MercPt = esri.geometry.webMercatorToGeographic(evt.mapPoint);    var theLong = MercPt.x;    var theLat = MercPt.y;    var didSucceed = window.clipboardData.setData('Text', '@Coord:' + theLong.toString() + ',' + theLat.toString() );   });

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??