Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a simple map with a set of 10 markers on it. When they are clicked an infoWindow appears however I would like to instead display the data in the infoWindow in a table. How do I find out which marker was clicked?

This is the code I'm using to determine which marker was clicked:

          // Find the identity of the marker that was clicked
          var selectQuery = new esri.tasks.Query();
          var tol = map.extent.getWidth()/map.width * 10;
          var x = evt.mapPoint.x;
          var y = evt.mapPoint.y;
          var queryExtent = new esri.geometry.Extent(x-tol,y-tol,x+tol,y+tol,evt.mapPoint.spatialReference);
          selectQuery.geometry = queryExtent;
          var t = featureLayer.selectFeatures(selectQuery,esri.layers.FeatureLayer.SELECTION_NEW);

This partially works, however when the map zooms out this code will sometimes the wrong marker information. I'm thinking that I can change the queryExtent variable to account for the zoom level of the map. Does anyone know if this would work?

Thank you for reading this question and hopefully someone more experienced than myself can help.

share|improve this question
up vote 1 down vote accepted

sorry but I couldn't reproduce it. But anyway, there is more easier way to get clicked feature from FeatureLayer. this is sample code

dojo.connect(featureLayer, "onClick", function (evt) {
    var graphicAttributes = evt.graphic.attributes;
    //do anything ...
share|improve this answer
That works perfectly! Thank you so much for taking the time to answer. – oborden2 Apr 15 '13 at 1:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.