openlayers-editor
openlayers-editor copied to clipboard
feat: add optional move event handler for cad
For the cad control a new option is exposed to allow the user to selectively handle move events and prevent lines from being drawn in certain cases. In our use case we use this to avoid showing snap guides when there is no feature currently being edited or drawn. Our use case does not use the controls bar and several custom interactions so we needed a way to decide if snapping should be actively shown based on the active move event.
Others
- [x] It's not a hack or at least an unauthorized hack :).
- [x] Everything in ticket description has been fixed.
- [x] The author of the MR has made its own review before assigning the reviewer.
- [x] The title is formatted as a conventional-commit message.
IMPORTANT: Squash commits before or on merge to prevent every small commit being written into the change log. The Pull Request title will be written as message for the new commit containing the squashed commits and there fore needs to be in conventional-commit format
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
openlayers-editor | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Aug 9, 2023 3:59pm |
We have the same usecase to achieve this, we activate the cad interaction on drawstart
or m̀odifystart events and deactivate it on
drawendor
modifyend` events . Which is probably where you set the handleMoveEvent property, am I wrong ?
So I don't think this property is needed.
Similar use case, however, in our use case and the way we have the app structured our snapping management is configured separately from our editing management. Our snapping manager only knows about the ole.Editor
currently and the draw/modify controls do not know if snapping is being applied.
The way we are using this on my fork is
handleMoveEvent: () => {
const handleEvent = !isSnappingDisabled || !!editor.getEditFeature() || !!editor.getDrawFeature();
return handleEvent;
},
If the editor fired off events when the editFeature
and drawFeature
objects changed that way you proposed would be easy for us to do. Unfortunately the Editor's don't currently provide any event management