dojo.connect(map, "onClick", function (evt) { var query = new esri.tasks.Query(); query.geometry = pointToExtent(map, evt.mapPoint, 10); //buffers click point by number of pixels(10) var deferred = featureLayerSeg.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW); deferred.addCallback(function (features) { console.log(features.length); //this returns 1 if the features are stacked on top of each other }); }
Solved! Go to Solution.
I am using the selectFeatures function to launch a popup when clicking on a feature. Because of the nature of my data, many of the features (street segments) have coincident geometry (they are stacked on top of each other). When I click on one of these segments that I know has multiple coincident features, the selectFeatures function only returns one feature (assuming the "top" one). If the features are adjacent (within my 10 pixel click buffer) but not coincident, it returns multiple features.
How can I have the selectFeatures return all features at that location, not just the one?dojo.connect(map, "onClick", function (evt) { var query = new esri.tasks.Query(); query.geometry = pointToExtent(map, evt.mapPoint, 10); //buffers click point by number of pixels(10) var deferred = featureLayerSeg.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW); deferred.addCallback(function (features) { console.log(features.length); //this returns 1 if the features are stacked on top of each other }); }
PS- I don't want to use IdentifyTask to a map service because these feature layers have already been filtered by the user based on search parameters.
Hi Jeff, thanks for your response. That seems like it would cause the same result I am seeing. However, I am using SNAPSHOT mode. I tried using .setAutoGeneralize(false) on my FeatureLayer before applying the setDefinitionExpression but it didn't make any difference.
var deferred = featureLayerSeg.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW); deferred.addCallback(function (features) { console.log(features.length); for(var i=0; i < features.length; i++) { console.log(features); //returns only one feature to Console- see attached screenshot } });
Useful?
I'm able to get this to work. More info: http://gis.stackexchange.com/a/22098/124