AnsweredAssumed Answered

Select features on multiple feature layers within Polygon

Question asked by tonylife on Aug 20, 2013
Latest reply on Jan 17, 2014 by ganeshssac
I am trying to get all features on multiple feature layers inside of a polygon.

I was doing polygon.contains(), it works great for point type feature layer, but not for polyline type or polygon type feature layer.

Then I was directed to implement this in different way, which is doing query on feature layer, by setting query.geomotry = polygon.geometry.
It works fine for single layer, but when it comes to multiple layers, I have trouble to get correct result.
What I am getting, is always the selected features for last layer. Does it clear the selectFeatures result from previous layer every time run for next layer? I did try SELECTION_ADD mode, which is not working either.

Here is the code
var query = new esri.tasks.Query(); query.geometry = area.geometry; var counter = 0; var listOfSelectedFeatures; for (var j = 0; j < map.graphicsLayerIds.length; j++) {  var currentLayer = map.getLayer(map.graphicsLayerIds[j]);      currentLayer.selectFeatures(query, currentLayer.SELECTION_NEW, function () {   counter++;   if (counter == (map.graphicsLayerIds.length - 1)) {    for (var k = 0; k < map.graphicsLayerIds.length; k++) {     var layer = map.getLayer(map.graphicsLayerIds[k]);     if (listOfSelectedFeatures == undefined) {      listOfSelectedFeatures = layer.getSelectedFeatures();     } else {      listOfSelectedFeatures.concat(layer.getSelectedFeatures());     }    }   }  }); }                


Thanks,
Tony

Outcomes