mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Rendering curved lines

Open peterqliu opened this issue 5 years ago • 5 comments

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

  1. we want actual curves, or
  2. 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

  1. can greatly bloat the size of the line geometry, and
  2. 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.

peterqliu avatar Jul 16 '18 17:07 peterqliu

is this feature (or any kind of curve smoothing) planned for the near future?

waissbluth avatar Mar 13 '20 19:03 waissbluth

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.

asheemmamoowala avatar Mar 16 '20 21:03 asheemmamoowala

Is there any development on bezier cureve by mapbox? Like the one on the studio. any code example on how to use it ?

m90khan avatar Jul 20 '21 20:07 m90khan

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

Jeff-Numix avatar Sep 07 '21 20:09 Jeff-Numix

Any news about this feature ?

yacineblr avatar Jul 08 '22 15:07 yacineblr