我正在尝试将具有不同范围的多个Openlayer图像层(使用栅格源)添加到单个Map中。如果添加单个图层,则显示该图层,但添加多个图层均不显示。
zindex
是我试图更改而没有用的问题。记录层数总是显示所有3层(我添加了2层,还有1个基本层,即地图)
this.raster = new RasterSource({
sources: [this.layer.getSource()],
operation: (pixels, data) => {
let pixel = pixels[0];
pixel[0] = 0;
pixel[1] = 255;
pixel[2] = 0;
return pixel;
}
});
let previewColorLayer = new ImageLayer({
opacity: 0.4,
source: this.raster,
extent: [972.145, 1948.98, 1270.395, 2082.48],
zIndex: 1000
// extent: ex
});
let previewColorLayer2 = new ImageLayer({
opacity: 0.4,
source: this.raster,
extent: [952.145, 1756.98, 1270.395, 1890.48],
zIndex: 2000
// extent: ex
});
this.overviewMap.getOverviewMap().addLayer(previewColorLayer);
this.overviewMap.getOverviewMap().addLayer(previewColorLayer2);
答案 0 :(得分:1)
我尝试将栅格图层示例分为两个范围,并遇到相同的问题,看来构造的源不能用于多个图层。但是您可以重复使用用于构建它的选项
this.rasterOptions = {
sources: [this.layer.getSource()],
operation: (pixels, data) => {
let pixel = pixels[0];
pixel[0] = 0;
pixel[1] = 255;
pixel[2] = 0;
return pixel;
}
};
let previewColorLayer = new ImageLayer({
opacity: 0.4,
source: new RasterSource(this.rasterOptions},
extent: [972.145, 1948.98, 1270.395, 2082.48],
zIndex: 1000
// extent: ex
});
let previewColorLayer2 = new ImageLayer({
opacity: 0.4,
source: new RasterSource(this.rasterOptions},
extent: [952.145, 1756.98, 1270.395, 1890.48],
zIndex: 2000
// extent: ex
});