terra-draw
Version:
Frictionless map drawing across mapping provider
69 lines (68 loc) • 3.03 kB
TypeScript
import { TerraDrawMouseEvent } from "../../../common";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
import { MidPointBehavior } from "./midpoint.behavior";
import { SelectionPointBehavior } from "./selection-point.behavior";
import { FeatureId } from "../../../store/store";
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
import { ReadFeatureBehavior } from "../../read-feature.behavior";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
export type ResizeOptions = "center" | "opposite" | "center-fixed" | "opposite-fixed";
export declare class DragCoordinateResizeBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly pixelDistance;
private readonly selectionPoints;
private readonly midPoints;
private readonly coordinatePoints;
private readonly readFeature;
private readonly mutateFeature;
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior, readFeature: ReadFeatureBehavior, mutateFeature: MutateFeatureBehavior);
private minimumScale;
private draggedCoordinate;
private boundingBoxMaps;
private getClosestCoordinate;
private isValidDragWebMercator;
private getSelectedFeatureDataWebMercator;
private centerWebMercatorDrag;
private centerFixedWebMercatorDrag;
private scaleFixedWebMercator;
private oppositeFixedWebMercatorDrag;
private oppositeWebMercatorDrag;
private scaleWebMercator;
private getFeature;
private getNormalisedCoordinates;
private validateScale;
private performWebMercatorScale;
private getBBoxWebMercator;
private getIndexesWebMercator;
/**
* @returns - true if the feature is being dragged (resized), false otherwise
*/
isDragging(): boolean;
/**
* Starts the resizing of the feature
* @param id - feature id of the feature that is being dragged
* @param index - index of the coordinate that is being dragged
* @returns - void
*/
startDragging(id: FeatureId, index: number): void;
/**
* Stops the resizing of the feature
* @returns - void *
*/
stopDragging(): void;
/**
* Returns the index of the coordinate that is going to be dragged
* @param event - cursor event
* @param selectedId - feature id of the feature that is selected
* @returns - the index to be dragged
*/
getDraggableIndex(event: TerraDrawMouseEvent, selectedId: FeatureId): number;
/**
* Resizes the feature based on the cursor event
* @param event - cursor event
* @param resizeOption - the resize option, either "center" or "opposite"
* @returns - true is resize was successful, false otherwise
*/
drag(event: TerraDrawMouseEvent, resizeOption: ResizeOptions): boolean;
}