【发布时间】:2019-04-10 03:42:21
【问题描述】:
如何在 Openlayers 5 / Typescript 中执行此操作?
有没有办法(也)识别绘制的矩形?矢量图层上可能还有其他特征。
解决方案:
import {Draw} from 'ol/interaction';
import {createBox} from 'ol/interaction/Draw';
startDrawingRectangular() {
const geomFunction = createBox();
this.draw = new Draw({
source: this.vectorLayer.getSource(),
type: 'Circle',
geometryFunction: geomFunction
});
this.map.addInteraction(this.draw);
const that = this;
this.draw.on('drawend', (event) => {
that.map.removeInteraction(this.draw);
that.savedPolygon = event.feature.getGeometry();
that.draw = null;
});
}
【问题讨论】:
-
'drawend'事件中新绘制的特征是event.feature