设置面图层纹理重复
可以设置面图层的贴图重复次数,建议数值为2的幂次方。

<!DOCTYPE html>
<html>
<head>
<title>面图层纹理重复</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.3.0/mapmost-webgl-min.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
let map = new mapmost.Map({
bearing:-23.995313758470502,
center:[120.73220073317424, 31.33096911274842],
pitch:61.25030888006924,
zoom:16.400520362885048,
container: 'map',
style: "<your style url>",
sky: 'light',
userId: '***', // 授权码
});
map.on('load', () => {
// 添加图片资源
map.loadImage('./static/Grass_51.png', function (error, img) {
map.addImage('grass1', img);
// 添加面图层
map.addLayer({
"id": "landuse_forest",
"type": "fill",
"source": "wp2wqan1i",
"source-layer": "landuse",
"minzoom": 14,
"filter": ["all", ["in", "fclass", "forest", "park"]],
"paint": {
"fill-pattern": "grass1", // 设置贴图
"fill-pattern-density": { // 设置贴图重复次数
"stops": [
[14, 3],
[17, 6]
]
}
}
}, "landuse_culture")
});
})
</script>
</body>
</html>