geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

Feature: Draw rectangles at angle, determined by a line. #1323

Open strfx opened 1 year ago

strfx commented 1 year ago

Hi there!

I think it would be great to have a feature that lets users draw rectangles at an angle, based on a previously drawn line. I hacked together a proof of concept to demonstrate the idea:

example-rotated-rectangle

You can play around with the example in this JSFiddle: https://jsfiddle.net/n9kz4atx/24/.

What do you think? I'd be excited to work on a PR if this is something you'd like to have in geoman.

Thanks for the great work!

Falke-Design commented 1 year ago

Nice idea, but I don't know if we should implement it in the core code. I will discuss it with @codeofsumit

codeofsumit commented 1 year ago

@strfx this look great. I talked with @Falke-Design and we would appreciate a pull request that implements this as follows:

  1. Add a global option adjustRectAngleWhileDraw - default is false
  2. If set to true, the behavior shown in the GIF should be the default when in Draw Mode for Rectangles.
strfx commented 1 year ago

thanks for the feedback @codeofsumit and @Falke-Design - approach sounds sensible! Will follow up with a PR soon.