VectorTileLayer - 更新样式

尝试一下在线预览

这个例子展示了如何在 VectorTileLayer当前样式 中更新 样式图层

在 VectorTileLayer 的 4.18 版本中,我们引入了以下方法,它们将在 VectorTileLayer 的 currentStyleInfo.style 中获取和设置样式图层的各种属性。这些方法可以在 2D  MapView 中使用,而不需要重新加载整个 VectorTileLayer 。

               
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// delete a style layer
layer.deleteStyleLayer("City small scale/medium other capital");

// add a new style layer at the specified index
layer.setStyleLayer(styleLayer, 15);

// make a layer visible
layer.setStyleLayerVisibility("Admin0 point/medium", "visible");

// change style layer paint and layout properties at once
const styleLayer = layer.getStyleLayer("City small scale/x large admin0 capital");
styleLayer.paint["text-color"] = "#E400E0";
styleLayer.paint["text-halo-color"] = "#E400E0";
styleLayer.layout["icon-size"] = 1.5;
layer.setStyleLayer(styleLayer);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.