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 featureLayer.clearSelection(); 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); console.log(t.results.attributes);
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.