UNPKG

rlayers

Version:

React Components for OpenLayers

26 lines 984 B
import { default as Draw } from 'ol/interaction/Draw'; import { default as RPointer } from './RPointer'; /** Pointer interaction for drawing features */ class RDraw extends RPointer { createOL(props) { var _a; if (!((_a = this === null || this === void 0 ? void 0 : this.context) === null || _a === void 0 ? void 0 : _a.vectorsource)) throw new Error('A Draw interaction must be part of a vector layer'); this.classProps = RDraw.classProps; return new Draw(Object.assign({ type: props.type, source: this.context.vectorsource }, Object.keys(props) .filter((p) => this.classProps.includes(p)) .reduce((ac, p) => (Object.assign(Object.assign({}, ac), { [p]: props[p] })), {}))); } } RDraw.classProps = [ 'condition', 'finishCondition', 'freehandCondition', 'style', 'stopClick', 'maxPoints', 'minPoints', 'snapTolerance' ]; export default RDraw; //# sourceMappingURL=RDraw.js.map