/** * MobileDraw Interaction. * * @typedef {Object} MobileDrawOptions * @property {number} [minPoints] The number of points that must be drawn before a polygon ring or line * string can be finished. Default is `3` for polygon rings and `2` for line strings. * @property {import('ol/style/Style').StyleLike} [style] Style for sketch features. * @property {string} type Drawing type ('Point' or 'LineString'. * @property {boolean} [wrapX] Wrap the world horizontally on the sketch overlay. Default is `false`. */ /** * Interaction for drawing feature geometries from a mobile device using the * center of the map view as entry for points added. * * Supports: * - point * - line string * - polygon * * @hidden */ export default class _default extends olInteractionInteraction { /** * @fires DrawEvent * @param {MobileDrawOptions} options Options */ constructor(options: MobileDrawOptions); /** * The key for view center change event. * * @type {?import('ol/events').EventsKey} * @private */ private changeEventKey_; /** * Geometry type. * * @type {string} * @private */ private type_; /** * The number of points that must be drawn before a polygon ring or line * string can be finished. The default is 3 for polygon rings and 2 for * line strings. * * @type {number} * @private */ private minPoints_; /** * Sketch feature. * * @type {?olFeature} * @private */ private sketchFeature_; /** * Previous sketch points, saved to be able to display them on the layer. * * @type {olFeature[]} * @private */ private sketchPoints_; /** * Current sketch point. * * @type {?olFeature} * @private */ private sketchPoint_; /** * Draw overlay where our sketch features are drawn. * * @type {import('ol/layer/Vector').default>} * @private */ private overlay_; /** * Return whether the interaction is currently dirty. It is if the sketch * feature has its geometry last coordinate set to the center without the * use of the `addToDrawing` method. * * @returns {boolean} `true` if the interaction is dirty, `false` otherwise. * @observable */ getDirty(): boolean; /** * Return whether the interaction is currently drawing. * * @returns {boolean} `true` if the interaction is drawing, `false` otherwise. * @observable */ getDrawing(): boolean; /** * Return whether the interaction as a valid sketch feature, i.e. its geometry * is valid. * * @returns {boolean} `true` if the interaction has a valid sketch feature, * `false` otherwise. * @observable */ getValid(): boolean; /** * Returns the current sketch feature. * * @returns {?olFeature} The sketch feature, or null if none. */ getFeature(): olFeature | null; /** * Add current sketch point to sketch feature if the latter exists, else create * it. */ addToDrawing(): void; /** * Clear the drawing */ clearDrawing(): void; /** * Finish drawing. If there's a sketch point, it's added first. */ finishDrawing(): void; /** * Start drawing by adding the sketch point first. * * @private */ private startDrawing_; /** * Modify the geometry of the sketch feature to have its last coordinate * set to the center of the map. * * @private */ private modifyDrawing_; /** * Stop drawing without adding the sketch feature to the target layer. * * @returns {?olFeature} The sketch feature (or null if none). * @private */ private abortDrawing_; /** * @private */ private updateState_; /** * @param {Event|import('ol/events/Event').default} evt Event. * @private */ private handleViewCenterChange_; /** * @private */ private createOrUpdateSketchPoint_; /** * Redraw the sketch features. * * @private */ private updateSketchFeatures_; /** * Returns the geometry of the sketch point feature. * * @returns {import('ol/geom/Point').default} Point. * @private */ private getSketchPointGeometry_; /** * Returns the center of the map view * * @returns {import('ol/coordinate').Coordinate} Coordinate. * @private */ private getCenter_; } /** * MobileDraw Interaction. */ export type MobileDrawOptions = { /** * The number of points that must be drawn before a polygon ring or line * string can be finished. Default is `3` for polygon rings and `2` for line strings. */ minPoints?: number; /** * Style for sketch features. */ style?: import("ol/style/Style").StyleLike; /** * Drawing type ('Point' or 'LineString'. */ type: string; /** * Wrap the world horizontally on the sketch overlay. Default is `false`. */ wrapX?: boolean; }; import olInteractionInteraction from 'ol/interaction/Interaction'; import olFeature from 'ol/Feature';