Openlayers 5 Typescript - интерактивно рисовать фигуры - PullRequest
1 голос
/ 07 апреля 2019

Как я могу сделать это в 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;
    });
}

1 Ответ

1 голос
/ 07 апреля 2019

Один из способов получить нарисованную функцию

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