2

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 stacked 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 does return 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.

1 Answer 1

2

I'm able to use featureLayer.selectFeatures() to get coincident features. My test is here: http://jsfiddle.net/xnNar/

The one thing I'd check is that your feature layer has a field with type esriFieldTypeOID and that your object IDs are unique.

The JSON for an object ID field looks like this:

{
  "name": "objectid",
  "type": "esriFieldTypeOID",
  "alias": "Object ID"
}
5
  • 1
    Thanks Derek, it turns out the OBJECTID in my SDE View is not actually unique. I will have to sort out my view but it appears that this is likely the issue. As soon as I test with a unique OBJECTID I will mark this as answered. Thanks again for your help. Commented Mar 22, 2012 at 13:05
  • 1
    Yes, once the map service that my FeatureLayer was derived from had unique OBJECTIDs, all the features were returned in selectFeatures. Thanks again Derek! Commented Mar 23, 2012 at 19:33
  • Glad you got it working! Commented Mar 23, 2012 at 19:41
  • I tried your solution and everything "seems" to work fine, but not always. With your lines example in JSFIDDLE, if you go down to the closer scale (level 21 I suppose) and click several times on different points of the line, sometimes you get a popup with the text "(1 of 3)" in the black section of the popup and sometimes you get the text "Buck Creek 3". Once you press in the arrow keys of the popup, this title doesn't return, you will always have the "(x of 3)" text and, besides, the order is a bit strange. Pressing the right arrow, it passes from "Buck Creek 3" to "Buck Creek 2" and after th Commented Feb 13, 2013 at 16:06
  • Welcome to our site, Santiago! Here, we use comment boxes for comments and ask follow-up questions in new threads. Please consult our faq for more information. I have converted your text to a comment, rather than deleting it entirely, so that your information will remain available here, but it was too long for all of it to be retained.
    – whuber
    Commented Feb 13, 2013 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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