hcphoon
hcphoon

Reputation: 548

Mapbox 3D line workaround

I have a map from mapbox that has multiple markers as coordinates and one line that joins them together, I've experimented with the 3D feature and realised that at the moment lines cannot be extruded although polygons can.

So I was wondering if it is possible to convert my line into multiple different polygons to be able to extrude it at different heights, either that or set each marker as its own height then create a line/polygon that joins them together?

Upvotes: 4

Views: 2751

Answers (2)

Fabian
Fabian

Reputation: 1

you can have a look at deck.gl, they can have lat, lng, and altitude for each basepoint of a line https://deck.gl/examples/line-layer

Upvotes: 0

AndrewHarvey
AndrewHarvey

Reputation: 3055

What you're asking for isn't yet implemented, but ticketed in Mapbox GL JS at https://github.com/mapbox/mapbox-gl-js/issues/3993.

For now you'll need to opt for converting the LineString feature to a Polygon. You can do this with turf's buffer function http://turfjs.org/docs#buffer.

The whole line/polygon will be offset at the same height, so depending on your application you could use turf's linkChunk http://turfjs.org/docs#lineChunk to get it broken up into smaller features which you assign different height properties to.

Upvotes: 0

Related Questions