UNPKG

terra-draw

Version:

Frictionless map drawing across mapping provider

99 lines (98 loc) 3.86 kB
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, DrawInteractions } from "../../common"; import { BaseModeOptions, CustomStyling, ModeUpdateOptions, TerraDrawBaseDrawMode } from "../base.mode"; import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store"; import { BehaviorConfig } from "../base.behavior"; type TerraDrawFreehandModeKeyEvents = { cancel: KeyboardEvent["key"] | null; finish: KeyboardEvent["key"] | null; }; type FreehandPolygonStyling = { fillColor: HexColorStyling; fillOpacity: NumericStyling; outlineColor: HexColorStyling; outlineOpacity: NumericStyling; outlineWidth: NumericStyling; closingPointColor: HexColorStyling; closingPointOpacity: NumericStyling; closingPointWidth: NumericStyling; closingPointOutlineColor: HexColorStyling; closingPointOutlineOpacity: NumericStyling; closingPointOutlineWidth: NumericStyling; }; interface Cursors { start?: Cursor; close?: Cursor; } interface TerraDrawFreehandModeOptions<T extends CustomStyling> extends BaseModeOptions<T> { minDistance?: number; smoothing?: number; preventPointsNearClose?: boolean; autoClose?: boolean; autoCloseTimeout?: number; keyEvents?: TerraDrawFreehandModeKeyEvents | null; cursors?: Cursors; drawInteraction?: DrawInteractions; } export declare class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<FreehandPolygonStyling> { mode: string; private canClose; private currentId; private closingPointId; private minDistance; private keyEvents; private cursors; private preventPointsNearClose; private autoClose; private autoCloseTimeout; private hasLeftStartingPoint; private preventNewFeature; private drawInteraction; private drawType; private smoothing; private mutateFeature; private readFeature; constructor(options?: TerraDrawFreehandModeOptions<FreehandPolygonStyling>); updateOptions(options?: ModeUpdateOptions<TerraDrawFreehandModeOptions<FreehandPolygonStyling>>): void; private moveDrawAllowed; private dragDrawAllowed; private beginDrawing; private addCoordinate; /** * Uses a simple linear interpolation to smooth the coordinates. The smoothing factor determines how * much influence the previous coordinate has on the new coordinate. A smoothing factor of 0 means * no smoothing (the target coordinate is used as is), while a smoothing factor close to 1 means a * lot of smoothing (the new coordinate will be very close to the previous coordinate). * The default value is 0, which means no smoothing. * @param previousCoordinate * @param targetCoordinate * @returns */ private getSmoothedCoordinate; private close; /** @internal */ start(): void; /** @internal */ stop(): void; /** @internal */ onMouseMove(event: TerraDrawMouseEvent): void; /** @internal */ onClick(event: TerraDrawMouseEvent): void; /** @internal */ onKeyDown(): void; /** @internal */ onKeyUp(event: TerraDrawKeyboardEvent): void; /** @internal */ onDragStart(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void; /** @internal */ onDrag(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void; /** @internal */ onDragEnd(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void; /** @internal */ cleanUp(): void; /** @internal */ styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling; validateFeature(feature: unknown): StoreValidation; afterFeatureUpdated(feature: GeoJSONStoreFeatures): void; registerBehaviors(config: BehaviorConfig): void; } export {};