mapbox-gl-js
mapbox-gl-js copied to clipboard
Rendering curved lines
Motivation
Both the GeoJSON and vector tile specifications encode line geometry as discrete points, with straight line segments connecting them. This is a great, lightweight format to store and render geometry, but makes it difficult to render curves, either when
- we want actual curves, or
- when we want to draw complex, organic shapes with minimal number of vertices. Curves would allow us to approximate the original line by applying smoothening on the render side.
https://github.com/mapbox/mapbox-gl-js/issues/981 and https://github.com/mapbox/mapbox-gl-js/issues/4180 are related, except they're for camera movements
Design Alternatives
My current workaround is simply to manipulate the source geometry (via turf.bezierSpline and the like), adding more vertices to improve perceived smoothness.
Design
The current workflow is not ideal, because it
- can greatly bloat the size of the line geometry, and
- is never actually infinitely smooth (as far as the current screen resolution allows)
Preliminary reading suggests that this is possible on the rendering side, possibly more efficiently than by data manipulation.
Mock-Up
Some kind of line-bezier
property, with dimensionless values like in CSS, or resolution and sharpness, or something else.
is this feature (or any kind of curve smoothing) planned for the near future?
This has been proposed in the vector tile spec and is being tracked at https://github.com/mapbox/vector-tile-spec/issues/114. There are no current plans to incorporate this into GL-JS separate from that spec.
Is there any development on bezier cureve by mapbox? Like the one on the studio. any code example on how to use it ?
I developed a bezier curve drawing mode for mapbox gl draw. I hope it can be usefull to you : https://github.com/Jeff-Numix/mapbox-gl-draw-bezier-curve-mode
Any news about this feature ?