18

So, I'm trying to draw curved lines in my application which is based on a Leaflet map.

As far as I know Leaflet does not support drawing curved lines at the moment, so my question is really more about how to best get some curved line funtionality in there.

The problem is made more difficult because my code will have to be IE-8 compatible, which means that pure SVG is no solution. (Leaflet actually does a fall-back to VML if it detects that no SVG support is present...)

So one possibility would be to myself write some leaflet extension code based on SVG with its own fallback to VML. This would be a hell of a lot of work. :/

Does anyone have a better proposition?

1
  • Just now realized that I never accepted an answer. I picked the one by @dobrych because Raphaël seems to be a very nice library and provides a nice VML fallback. I might look into the arc.js as well.
    – fgysin
    Commented Nov 11, 2013 at 8:07

3 Answers 3

8

You can use the arc.js plugin for leaflet to draw curved lines.

1
  • 1
    Arc.js draws great circle routes, not arbitrary curves. Commented Jul 8, 2016 at 15:46
5

Considering IE8 support requirement, we don't have many options on the table. I can only recall one SVG lib that has VML fallback — Raphaël.js So you can try this Raphaël layer plugin implementation for Leaflet. https://github.com/dynmeth/RaphaelLayer I didn't try plugin myself, but successfully used Raphaël. Hope you can find a use of it.

Here is the working example (picture links to demo) http://visualizingurbanfutures.com/2012/09/06/maps-with-raphael-js/

If not IE8 requirement, I would go to use D3 for any vectors in web GIS.

3

Making your own custom layer is probably one solution to solve that issue. But yes, i agree it would be a hell lot of work. Another option would be to draw your own curves (bezier, b-spline or something like that) based on the geographic coordinates. I have no idea if that looks nice, but I could imagine that the result would not be too bad and it is definetly a lot faster achieved. There is plenty of JS scripts for such algorithms around. It might be worth considering to project your data into something like UTM for the calculation.

If you find smth. out please let us know...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.