如何在地图的某个区域内显示切片图层?尝试使用“范围”选项,但它对我不起作用。
这就是我尝试这样做的方式:
var polygon = rm.getCurrentRegion().getData().polygon; //get a polygon
var extent = new ol.geom.Polygon([polygon]).getExtent(); //convert it to an extent
let newLayer = new CommonMap.TileLayer({
type: LayerTypes.CUSTOM_WMS_LAYER + ('_' as any) + Base.getUid(),
group: LayerGroups.CUSTOM_WMS_LAYERS,
source: new ol.source.TileWMS({
url: `/maps/get?url=${this.url}` + query,
params: $.extend(
{ 'LAYERS': layers.map(l => l.key).join(',') },
styles ? { 'STYLES': styles.map(s => s.key).join(',') } : {}
),
wrapX: true,
projection: mm.getMap().getView().getProjection()
}),
extent: extent //doesn't work
});
newLayer.setExtent(extent); //doesn't work