mapbox - 在 MapBox 中挤压土地
问题描述
我想强调一个事实,即在我的地图中土地高于水,因此想在土地图层中添加一个挤压。我认为https://docs.mapbox.com/mapbox-gl-js/example/3d-buildings/
使用建筑物并将图层源更改为“土地”会起作用,但事实并非如此。这是特定于构建层的东西还是我做错了什么?这是我的样式 JSON 中的层定义:
{
"id": "3d-land",
"source": "composite",
"source-layer": "land", # Changed this from building
"filter": ["==", "extrude", "true"],
"type": "fill-extrusion",
"minzoom": 0,
"paint": {
"fill-extrusion-color": "#000",
"fill-extrusion-height": [
"interpolate", ["linear"], ["zoom"],
15, 0,
18.0, 30.0
],
"fill-extrusion-base": [
"interpolate", ["linear"], ["zoom"],
15, 0,
18.0, ["get", "min_height"]
],
"fill-extrusion-opacity": 0.8
}
}
解决方案
第一个原因正如控制台所说,"land" does not exist on source "composite"
. "land"
layer 是background
样式中单独存在的图层。您不能fill-extrusion
用于background
图层。您可能想要使用使用"compose"
源的图层。
另一个原因来自filter
。"filter": ["==", "extrude", "true"]
表示如果 layer 的属性名为"extrude"
is ,则进行过滤"true"
。land
layer 没有属性extrude
,所以它总是false
.
因此,修复的结果将如下所示:
map.addLayer(
{
id: "3d-landcover",
source: "composite",
"source-layer": "landcover",
"type": "fill-extrusion",
"minzoom": 0,
"paint": {
"fill-extrusion-color": "#000",
"fill-extrusion-height": [
"interpolate", ["linear"], ["zoom"],
15, 0,
18.0, 30.0
],
"fill-extrusion-base": [
"interpolate", ["linear"], ["zoom"],
15, 0,
18.0, ["get", "min_height"]
],
"fill-extrusion-opacity": 0.8
}
}
);
作为第一个原因,如果要使土地高于水,则应按上述添加除水以外的所有层。这不是很有效。
推荐阅读
- elasticsearch - Elasticsearch Aggregations:使用嵌套查询过滤全局聚合
- kubernetes - NGINX 入口控制器在 60 秒后超时请求
- android - 将 Adapter 的结果返回给 Activity
- java - 如何使用 BouncyCastle 从字符串生成私钥
- c# - 使用带有自动映射器 MapFrom 的嵌套属性字符串
- ios - 是否有一个插件/库允许从库和 iCloud 中选择 iOS 文件?
- vim - 如何让 vim 将 $ 视为标识符字符?
- python - 为根记录器配置格式
- r - 使用 for 循环整理工作 R 代码
- arrays - 使用 Array/VLOOKUP 从列表创建总和