在地图的特定区域内显示切片图层

时间:2017-07-20 10:27:50

标签: openlayers openlayers-3

如何在地图的某个区域内显示切片图层?尝试使用“范围”选项,但它对我不起作用。

这就是我尝试这样做的方式:

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

0 个答案:

没有答案