featureLayer.queryFeatures(query) not working with spatialRelationship

1746
1
Jump to solution
05-22-2018 09:29 AM
DirkVandervoort
Occasional Contributor II

Greetings!

JSAPI 4.7

The user workflow is to have a user draw a polygon over some linear features. At "draw-complete" the polygon is coerced to a polyline and I want to find the line features that intersect the drawn polyline.

However the query informs me:

{"error":{"code":400,"message":"Unable to complete operation.","details":["Unable to perform query operation."]}}

The code appears simple enough:

action.on("draw-complete", function(evt){
   // create a polyline from the drawn polygon evt.verticies
   let selectionPolyline = new Polyline(evt.vertices);
   // get the gas line layer from the layers in the map using the title
   let gasLineLayer = mapView.map.allLayers.find(function(layer) {
      return layer.title === GAS_LINE_LAYER_TITLE;
   });
   let query = new Query({
      geometry: selectionPolyline,
      spatialRelationship: "intersects"
   });
   gasLineLayer.queryFeatures(query).then(function(evt){
      alert("SUCCESS");
   })
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

If I do a simple query with just a where:'1=1', all features are selected, so it must be something in the query definition about the spatialRelationship. Are spatial references this issue perhaps?

Help please. TIA!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Dirk,

   The draw-complete event returns a Geometry so I am not sure where you saw in the documentation that a geometry has a vertices property. A Polygon geometry has Rings property:

https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#rings 

View solution in original post

1 Reply
RobertScheitlin__GISP
MVP Emeritus

Dirk,

   The draw-complete event returns a Geometry so I am not sure where you saw in the documentation that a geometry has a vertices property. A Polygon geometry has Rings property:

https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#rings