JS-API: featureLayer.selectFeatures

3699
4
Jump to solution
11-30-2015 05:43 AM
ChrisPag
New Contributor II

Hi,

is there any posibility to select only the Features located inside the Selection-Geometry?
The Method featureLayer.selectFeatures(query,FeatureLayer.SELECTION_NEW) as well takes
the Features intersecting the shape of the Selection-Geometry

Chris

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You're correct. That should have been SPATIAL_REL_CONTAINS

View solution in original post

4 Replies
KenBuja
MVP Esteemed Contributor

You can set the spatialRelationship method of the Query task. By default, it's SPATIAL_REL_INTERSECTS, but you can set it to SPATIAL_REL_WITHIN.

0 Kudos
ChrisPag
New Contributor II
Hi,

    thank you for the response. Your Suggestion works in the wrong direction.

    I want to select all PolygonFeatures from FLayer located completly in

    a handdrawn Polygon called geo.

    SPATIAL_REL_WITHIN gives a result if geo is complete located in one Feature

    of FLayer.

function clipFLayer(geo) {

  var selectionQuery = new esri.tasks.Query();

  selectionQuery.spatialRelationship = esri.tasks.Query.SPATIAL_REL_WITHIN;

  selectionQuery.geometry = geo;

  FLayer = new esri.layers.FeatureLayer(theService, {outFields: ["*"]});

  FLayer.selectFeatures(selectionQuery,esri.layers.FeatureLayer.SELECTION_NEW);

  FLayer.on("selection-complete", findRelatedRecords);

}

KenBuja
MVP Esteemed Contributor

You're correct. That should have been SPATIAL_REL_CONTAINS

ChrisPag
New Contributor II

Thank you!

0 Kudos