AnsweredAssumed Answered

featureLayer.queryFeatures(query) not working with spatialRelationship

Question asked by vandervoort on May 22, 2018
Latest reply on May 22, 2018 by rscheitlin

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!

Outcomes