Openlayers 光栅源不可见的多个ImageLayer

Openlayers 光栅源不可见的多个ImageLayer,openlayers,openlayers-5,Openlayers,Openlayers 5,我正在尝试将具有不同范围的多个Openlayer图像层(使用光栅源)添加到单个地图。如果我添加一个图层,它会显示,但添加多个图层也不会显示 我认为zindex是我试图改变的问题,但没有用 我测试了添加后删除一个,然后第二个显示(一个未删除) 记录层数始终显示所有3个层(2个我添加的层和1个基本层,即地图) 我尝试将一个光栅层示例分成两个区段,但遇到了相同的问题,似乎构造的源不能在多个层中使用。但是您可以重用用于构建它的选项 this.rasterOptions = { sources: [t

我正在尝试将具有不同范围的多个Openlayer图像层(使用光栅源)添加到单个地图。如果我添加一个图层,它会显示,但添加多个图层也不会显示

  • 我认为
    zindex
    是我试图改变的问题,但没有用
  • 我测试了添加后删除一个,然后第二个显示(一个未删除)
  • 记录层数始终显示所有3个层(2个我添加的层和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
    });
    
    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
    });