openlayers-editor icon indicating copy to clipboard operation
openlayers-editor copied to clipboard

feat: add optional move event handler for cad

Open megawac opened this issue 1 year ago • 3 comments

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

megawac avatar Aug 09 '23 15:08 megawac

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

vercel[bot] avatar Aug 09 '23 15:08 vercel[bot]

We have the same usecase to achieve this, we activate the cad interaction on drawstart or m̀odifystart events and deactivate it ondrawendormodifyend` events . Which is probably where you set the handleMoveEvent property, am I wrong ?

So I don't think this property is needed.

oterral avatar May 10 '24 11:05 oterral

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

megawac avatar May 22 '24 04:05 megawac