Hi,
In my application I'd like to trigger the "create features" event from the Editor Widget , using a separate submit button ... I could not find any samples for this activity in the JS API developers reference. I could find only a sample for disabling the form fields while creating features and it is working ...My requirement is to trigger the "create features" event from the Editor Widget , using a separate submit button. Any suggestions is highly appreciated...Thanks.
const createButton = (text, clickHandler) => {
const button = document.createElement('button');
button.type = 'button';
button.innerText = text;
button.onclick = clickHandler;
document.querySelector('.buttons').appendChild(button);
}
createButton ("Submit Feature", async ()=> {
console.log('submit');
const editorVM = editor.viewModel;
let creationAvailable = true;
editorVM.watch(['state', 'featureFormViewModel.feature'], () => {
if (editorVM.state === 'creating-features' && editorVM.featureFormViewModel.feature && editorVM.featureFormViewModel.state === 'ready') {
editorVM.sketchViewModel.on('update', (event) => {
if (editorVM.featureFormViewModel.state === 'ready' && editorVM.sketchViewModel.activeTool === 'transform') {
creationAvailable = false;
}
view.hitTest(event).then((response) => {
if ( ! creationAvailable && editorVM.sketchViewModel.activeTool !== 'reshape') {
editorVM.sketchViewModel.cancel();
// event.stopPropagation; // ?
return; // ?
}
});
});
}
});
editorVM.featureFormViewModel.on('submit', () => (creationAvailable = true));
});