Good Day
I have a user who wants to do a reasonably complex selection using the Sketch Widget. Currently, I'm exposing the Draw Polygon, Rectangle and Circle functions, which react to the "create" event:
this._sketchWidget.on("create", async (event) => {})
Which is fine, that works and I can select the map segment using those thee tools. The point selector responds to my "click" handler, which is also working properly, but what does the Lasso Tool throw for an event?
It's not a click event, it's not the Sketch View create or update event, and according to the documentation, none of the other events would make any sense:
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#events-summar...
Just so we're clear, this is the tool I'm talking about:
Are there any examples to show this feature working?
Thanks
Got it! Use a pointer-down, and pointer-up event, with a set flag:
this._view.on("pointer-down", (event) => {
this._view.hitTest(event).then((response) => {
if (response.results.length && this._sketchWidget.activeTool === 'lasso-selection') {
this.lassoSet = true;
}
});
});
this._view.on("pointer-up", (event) => {
this._view.hitTest(event).then((response) => {
if (response.results.length && this.lassoSet) {
this.lassoSet = false;
console.log('Response from Lasso Selection');
console.log(response);
}
});
});
Now I have a list of selected assets, so I can query them 🙂 - Hope this helps someone!
Thanks
Hi Andrew, This has been quite helpful. I'm having trouble retrieving the geometry of the lasso selection. Any suggestions on that?
Thanks in advance!
Dan
hopefully not too cryptic but on the code above on line 13 put something like:
Hi Aaron. Thanks for the tip. I'm making progress with that.