There's a way to do this with mapbox-gl-js using fill-extrusion
and extending the linestring to behave like a really thin polygon.
You can use lineToPolygon
from @turf/line-to-polygon
to convert lineStrings to polygon to get a fill-able GeoJSON like this one:
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"height":40},"geometry":{"type":"Polygon","coordinates":[[[58.7541522,55.7444],[48.7041522,55.7444],[48.704152205,55.744405],[58.754152205,55.744405],[58.7541522,55.7444]]]}}]}
And then use fill-extrusion
layer type to add it to map.
<Source
id="linestr"
geoJsonSource={{
type: "geojson",
data: geojson
}}
/>
<Layer
id="linestr"
sourceId="linestr"
type="fill-extrusion"
paint={{
"fill-extrusion-color": "#f00",
"fill-extrusion-base": 0.5,
"fill-extrusion-opacity": 0.5,
"fill-extrusion-height": ["get", "height"]
}}
/>
Here's the full example: https://codesandbox.io/s/trusting-currying-fpbqf