0 mapbox mapbox-gl mapbox-gl-js
我们目前正在从geojson数据将图层加载到mapbox GL中。如果我们的geojson具有包含点和多边形的要素集合,则由于需要设置图层类型,因此似乎没有办法同时显示mapbox gl。
有没有办法为图层设置多种类型?似乎无法处理多个。
map.addLayer({
"id": "route",
"type": "line", //THIS SEEMS TO BE THE LIMITATION
"source": "route",
});
Run Code Online (Sandbox Code Playgroud)
没错,GL JS每层不能处理多种类型。
但是,您可以通过创建多个图层来显示来自单一来源的多种几何类型:
map.addLayer({
"id": "route-line",
"type": "line",
"source": "route",
"filter": ["==", "$type", "LineString"]
});
map.addLayer({
"id": "route-point",
"type": "circle",
"source": "route",
"filter": ["==", "$type", "Point"]
});
map.addLayer({
"id": "route-fill",
"type": "fill",
"source": "route",
"filter": ["==", "$type", "Polygon"]
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
888 次 |
| 最近记录: |