elfalem / Leaflet.curve

A Leaflet plugin for drawing Bézier curves and other complex shapes.
Other
218 stars 52 forks source link

Could a .getBounds() method be added? #50

Open eric-g-97477 opened 2 years ago

eric-g-97477 commented 2 years ago

This is related to https://github.com/elfalem/Leaflet.curve/issues/49

As noted in the related leaflet-lasso ticket ( https://github.com/zakjan/leaflet-lasso/issues/50 ), there may be something this project can do to support such functionality.

The primary issue, I believe, is the lack of a .getBounds() method.

I am wondering how difficult it would be to add such a method to this project...?

elfalem commented 2 years ago

There is already a .getBounds() method although it's not documented. For example on the demo page, you can run L.rectangle(pathFive.getBounds()).addTo(map);. Note that the bounds could be somewhat exaggerated (i.e. not as tight as they could be).

eric-g-97477 commented 2 years ago

Great. Might be worth adding it to the documentation.

zakjan commented 2 years ago

Besides getBounds(), lasso plugin also requires toGeoJSON()

eric-g-97477 commented 2 years ago

I wonder if it would be possible to implement a simple version of toGeoJSON() using the output from the existing .trace() function with a default sampling distance of [0, 0.25, 0.75, 1]. It wouldn't be a perfect representation, but perhaps it would be good enough for what the lasso plugin requires.

Of course, it may be nice to provide a way to tune the sampling distance via a separate function on the object if increased accuracy is required, but I am guessing that for most cases, it would be.

elfalem commented 2 years ago

@eric-g-97477 that sounds like it would work. Unfortunately, I'm a little short on time at the moment so it will likely take me a while to get to it.