首页 > 解决方案 > 是否可以在开放层 6 中仅显示来自光栅静态图像层的图像的选定绘制多边形区域

问题描述

const imageProjection = new Projection({
        code: 'orto-image',
        units: 'pixels',
        extent: buffer(extent, 512)
      });

const imgSource = new Static({
        url: this.imgURL,
        projection: imageProjection,
        imageExtent: extent,
        imageSize: [this.imageData.width, this.imageData.height],
        imageLoadFunction : (image) => {
          image.getImage().src = this.imgURL;
          if (image.resolution === undefined) {
            image.resolution = (image.extent[3] - image.extent[1]) / image.image_.height;
          }
          image.state = 2; // ImageState.LOADED;
          image.unlistenImage_();
          image.changed();
        }
      });
const imageLayer = new ImageLayer({
          source: imgSource
        });
imageLayer.set('name', `testing`);
imageLayer.set('type', 'IMAGE');
this.currentMap().addLayer(imageLayer);
const polygonFeature = new Feature(
        new Polygon([arrayData])/* .transform('EPSG:4326', 'EPSG:3857') */);
      const source = new VectorSource({
        style: new Style({
          fill: new Fill({
            color: 'black'
          })
        })
      });
      source.addFeature(polygonFeature);
      const layer = new VectorLayer({
        source,
      });
      layer.set('name', 'polygonLayer');
this.currentMap().addLayer(layer);

标签: gisopenlayersrasteropenlayers-6angular-openlayers

解决方案


推荐阅读