【问题标题】:Openlayers 5 Typescript - interactively draw a shapeOpenlayers 5 Typescript - 交互式绘制形状
【发布时间】: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

标签: typescript openlayers-5


【解决方案1】:

获得刚刚绘制的特征的一种方法

this.draw.on('drawend',(event)=>{
  this.myLatestNewFeature = event.feature;
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 2019-03-18
    • 1970-01-01
    • 1970-01-01
    • 2016-05-08
    相关资源
    最近更新 更多