gis - 是否可以在开放层 6 中仅显示来自光栅静态图像层的图像的选定绘制多边形区域
问题描述
我正在使用开放的第 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);
- 我的最终输出是:带有底图和光栅图像和多边形的地图
- 多边形之外的需求应该禁用或不可见(如裁剪或遮罩)..
- 我没有使用 ol-ext
- 对此提出建议或帮助..提前感谢..并节省我的时间..
解决方案
推荐阅读
- sql - 做左外连接是正确的情况吗?
- laravel - 如何使用 jwilder/whoami 在 Docker 中显示 laravel 主页
- php - MySQL登录系统没有从数据库中获取结果
- ruby-on-rails - 使用 Webhook API Rails 6 收到 200 响应后呈现应用内消息
- node.js - 使用 express 访问节点中的请求参数
- c++ - 如何在销毁 boost::asio 实体时消除崩溃?
- python - Storing attribute twice with composition in python - is it memory inefficient?
- java - WebServiceIOException when testing a web service client using MockWebServiceServer
- python - accessing property in text response python 3
- python - Pandas group by and sum