How can I do this in Openlayers 5 / Typescript?
Is there a way (also) to identify the drawn rectangular? There may be other features on the vector layer.
SOLUTION:
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;
});
}