我如何用图像填充所选的多边形?MapBox为此具有特殊功能,或者我需要找到自己的方式来获得此功能?我需要用图像填充多边形,但始终将其作为图像背景-不再重复。有什么方法可以不重复地用图像填充多边形吗? (填充所有多边形,例如CSS中的background-cover)
您可以像在fill-pattern
的示例中一样使用https://docs.mapbox.com/mapbox-gl-js/example/fill-pattern/
map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/64px-Cat_silhouette.svg.png',
function(err, image) {
if (err) throw err;
map.addImage('pattern', image);
map.addLayer({
'id': 'pattern-layer',
'type': 'fill',
'source': 'source',
'paint': {
'fill-pattern': 'pattern'
}
});
}
);