I would like to disable the Sketch widget in the onCreate handle for state "complete".
If I do it via .destroy(); inside the handler, I get the following error
SketchViewModel.js:5 Uncaught (in promise) s {name: 'AbortError', details: undefined, message: 'Aborted'}
The only way I found to work is to fire the .destroy() after a timeout. Is there a better way?
const handleOnCreate = (event) => {
if (event.state === 'complete') {
// my processing
//setTimeout(() => {
currentSketch?.destroy();
//}, 200);
}
};
const sketchGraphicsLayer = mapView.map.findLayerById(layerName);
const sketch = new Sketch({
layer: sketchGraphicsLayer,
view: mapView,
});
sketch.on('create', function (event) {
handleOnCreate(event);
});
Creation Mode is continuous by default. Use single.
const sketch = new Sketch({
layer: sketchGraphicsLayer,
view: mapView,
creatioMode: "single"
})