Openlayers 5 Typescript - 交互式绘制形状
Openlayers 5 Typescript - interactively draw a shape
我如何在 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;
});
}
获取刚刚绘制的特征的一种方法
this.draw.on('drawend',(event)=>{
this.myLatestNewFeature = event.feature;
});
我如何在 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;
});
}
获取刚刚绘制的特征的一种方法
this.draw.on('drawend',(event)=>{
this.myLatestNewFeature = event.feature;
});