henrythasler / Leaflet.Geodesic

Add-on to draw geodesic lines with leaflet
GNU General Public License v3.0
154 stars 27 forks source link

A copy constructor #114

Open sutarmin opened 2 weeks ago

sutarmin commented 2 weeks ago

Hello Henry. Thank you for the lib!

Is there a way to create an instance of GeodesicLine from another GeodesicLine to copy the state from it and skip calculations? Like a copy constructor.

I want to draw three lines through the same points (line + border + invisible hover zone) and I'm looking for a way to make the calculations only once and reuse them for all lines.

henrythasler commented 2 weeks ago

I need to check. Regarding the border around the line: Maybe some CSS-magic can do the trick as is shown in the animated flightpath demo. Would be much cheaper than rendering two separate lines and you don't need to worry about their order.

sutarmin commented 2 weeks ago

Thank you for your answer and suggestion! Rendering just one line instead of three would certainly be better :)

Would it still be beneficial for this library to have a copy constructor for GeodesicLine? If that's something you can imagine is possible and would be useful, I can take a look at it and prepare a PR

henrythasler commented 2 weeks ago

Currently it's not possible to set the geometry. Not sure if this would be a common use-case but let me do some tests to evaluate this.