When I try to query data from a sketch on a particular layer, it never returns any results when I know they exist. This used to work for the older Sketch object, but it no longer works with the web component sketch object.
First I get the geometry from the sketch and I can see it has values in the geometry property
sketchGeometry = event.detail.graphics[0].geometry;
Then after I get the layer view I do the following to try and query the attribues from that layer:
view.whenLayerView(layerSketchFrom).then((layerView)
const query = parcelLayerView.layer.createQuery({
geometry: geometry,
outFields: ["*"],
spatialRelationship: "contains",
returnGeometry: true
});
parcelLayerView.queryFeatures(query).then(async (results) =>
When I look into the results variable, no results ever come back. This used to work perfectly before, so I'm very confused why the new object doesn't work like the old one.
Can someone please provide an example of how to properly query a layer using the geometry from the new web component sketch object?
Solved! Go to Solution.
Hi @dtstopper ,
Take a look at the Query a feature layer spatial tutorial or this codepen, which is the solution from the tutorial. Hopefully they will help.
Hi @dtstopper ,
Take a look at the Query a feature layer spatial tutorial or this codepen, which is the solution from the tutorial. Hopefully they will help.
Thank you @Sage_Wall , once I figured out that I had to create the event handler for the sketch tool before call arcgisMap.viewOnReady(), it worked with the example you gave me. I also had to add my layers after the arcgisMap.viewOnReady() function was completed.
Thank you again for your help!