跳到主要内容
版本:9.4.0

设置图层可视层级

可自定义设置当前图层可展示的最大与最小层级。

show
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>设置图层可视层级</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
<style>
body {
margin: 0;
padding: 0;
}

#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.4.0/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<script>
let map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.72541613154851, 31.31171803927643],
zoom: 14,
pitch:60,
userId: '***', // 授权码
});

map.on('load', function () {

// 设置图层 13-15 层内可见
map.addLayer({
"id": "building-hig",
"type": "fill-extrusion",
"source": "cultural",
"source-layer": "b_buildings",
"layout": {
"visibility": "visible",
},
"minzoom": 13,
"maxzoom": 15,
"paint": {
"fill-extrusion-height": ["get", "jzzgdgd"],
"fill-extrusion-color": {
"stops": [
[
14.5,
"rgba(252, 254, 255, 1)"
],
[
16,
"rgba(255, 255, 255, 1)"
]
]
},
"filter": [">=", "dscs", 18]
}
})
})
</script>
</body>
</html>