import { Evented } from 'leaflet'; import { Handler } from 'leaflet'; import { Icon } from 'leaflet'; import { IconOptions } from 'leaflet'; import * as L_2 from 'leaflet'; import { LatLng } from 'leaflet'; import { LatLngExpression } from 'leaflet'; import { Layer } from 'leaflet'; import { LeafletEvent } from 'leaflet'; import { LeafletMouseEvent } from 'leaflet'; import { Map as Map_2 } from 'leaflet'; import { Marker } from 'leaflet'; import { MarkerOptions } from 'leaflet'; import { Polyline } from 'leaflet'; export declare function createDefaultMarkerIcon(colors: Record): Icon; export declare function createDefaultMarkerIconSrc(colors: Record): string; export declare function createSvgDataUrl(src: string): string; export declare const defaultIcon: Icon; export declare type DefaultMarkerIconColors = { color1: string; color2: string; color3: string; color4: string; }; export declare class DraggableLinesDragMarker extends DraggableLinesMarker { _idx: number | [number, number]; _removeOnClick: boolean; _over: boolean; constructor(draggable: DraggableLinesHandler, layer: SupportedLayer, latlng: LatLngExpression, idx: number | [number, number], options: MarkerOptions, removeOnClick: boolean); onAdd(map: Map_2): this; onRemove(map: Map_2): this; getIdx(): number | [number, number]; handleClick(): void; } declare class DraggableLinesHandler extends DraggableLinesHandler_base { options: DraggableLinesHandlerOptions & Required>; _tempMarker?: DraggableLinesTempMarker; constructor(map: Map_2, options?: DraggableLinesHandlerOptions); addHooks(): void; removeHooks(): void; shouldEnableForLayer(layer: Polyline): boolean; handleLayerAdd: (e: { layer: Layer; }) => void; handleLayerRemove: (e: { layer: Layer; }) => void; handleLayerMouseOver: (e: LeafletMouseEvent) => void; handleLayerSetLatLngs: (e: LeafletEvent) => void; drawDragMarkers(layer: SupportedLayer): void; removeDragMarkers(layer: SupportedLayer): void; drawPlusMarkers(layer: SupportedLayer): void; removePlusMarkers(layer: SupportedLayer): void; drawTempMarker(layer: SupportedLayer, latlng: LatLng): void; removeTempMarker(): void; enableForLayer(layer: SupportedLayer): void; redrawForLayer(layer: SupportedLayer): void; disableForLayer(layer: SupportedLayer): void; redraw(): void; _getRoutePointIndexes(layer: SupportedLayer): number[] | undefined; } export default DraggableLinesHandler; declare const DraggableLinesHandler_base: new (map: Map_2) => Handler & Evented; export declare interface DraggableLinesHandlerOptions { enableForLayer?: LayerFilter; dragMarkerOptions?: (layer: SupportedLayer, i: number, length: number) => MarkerOptions; tempMarkerOptions?: (layer: SupportedLayer) => MarkerOptions; plusMarkerOptions?: (layer: SupportedLayer, isStart: boolean) => MarkerOptions; plusTempMarkerOptions?: (layer: SupportedLayer, isStart: boolean) => MarkerOptions; allowDraggingLine?: LayerFilter; allowExtendingLine?: LayerFilter; removeOnClick?: LayerFilter<[PolylineIndex]>; } export declare abstract class DraggableLinesMarker extends Marker { _draggable: DraggableLinesHandler; _layer: SupportedLayer; _isInsert: boolean; _dragIdx?: number | [number, number]; _dragFrom?: LatLng; constructor(draggable: DraggableLinesHandler, layer: SupportedLayer, latlng: LatLngExpression, isInsert: boolean, options?: MarkerOptions); onAdd(map: Map_2): this; onRemove(map: Map_2): this; abstract getIdx(): PolylineIndex; handleDragStart(e: LeafletEvent): void; handleDrag(): void; handleDragEnd(): void; } export declare class DraggableLinesPlusMarker extends DraggableLinesMarker { _idx: number | [number, number]; _tempMarker?: DraggableLinesPlusTempMarker; _tempMarkerOptions: MarkerOptions; constructor(draggable: DraggableLinesHandler, layer: SupportedLayer, latlng: LatLngExpression, idx: number | [number, number], options: MarkerOptions, tempMarkerOptions: MarkerOptions); onAdd(map: Map_2): this; onRemove(map: Map_2): this; getIdx(): number | [number, number]; handleMouseOver(e: LeafletMouseEvent): void; } export declare class DraggableLinesPlusTempMarker extends DraggableLinesTempMarker { _plusMarker: DraggableLinesPlusMarker; _idx: number | [number, number]; constructor(draggable: DraggableLinesHandler, layer: SupportedLayer, plusMarker: DraggableLinesPlusMarker, latlng: LatLngExpression, idx: number | [number, number], options: MarkerOptions); shouldRemove(latlng: LatLng): boolean; getRenderPoint(): { idx: number | [number, number]; closest: LatLng; }; fireMouseOver(): void; fireMouseMove(): void; fireMouseOut(): void; } export declare class DraggableLinesTempMarker extends DraggableLinesMarker { renderPoint?: RenderPoint; constructor(draggable: DraggableLinesHandler, layer: SupportedLayer, latlng: LatLngExpression, options: MarkerOptions); onAdd(map: Map_2): this; onRemove(map: Map_2): this; show(): void; hide(): void; isHidden(): boolean; getIdx(): PolylineIndex; handleClick(): void; shouldRemove(mouseLatlng: LatLng): boolean; getRenderPoint(mouseLatLng: LatLng): RenderPoint | undefined; updateLatLng(mouseLatLng: LatLng): false | undefined; handleMapMouseMove(e: LeafletMouseEvent): void; handleMapMouseOver(e: Event): void; fireMouseOver(): void; fireMouseMove(): void; fireMouseOut(): void; } export declare const endIcon: Icon; export declare function getFromPosition(arr: A, idx: PolylineIndex): T; export declare function getPlusIconPoint(map: L_2.Map, trackPoints: L_2.LatLng[], distance: number, atStart: boolean): L_2.LatLng; /** * Returns the index where a new route point should be inserted into the list of route points. * To be used for a line where the points returned by `getLatLngs()` (“track points”) are a route that has been calculated to be the best * connection between a set of waypoints (“route points”). Dragging starts on a segment between two track points, but should lead an additional * point in the set of route points rather than track points, so that the route can be recalculated. * @param map: The instance of `L.Map`. * @param routePoints: An array of coordinates that are the waypoints that are used as the basis for calculating the route. If an array * of numbers is passed instead, these are assumed to be the already calculated fractional indexes for the route points as returned by * `locateOnLine`. * @param trackPoints: An array of coordinates as returned by `layer.getLatLngs()`. * @param point: An instance of `L.LatLng` that represents the point on the line where dragging has started. If a number is passed instead, * it is assumed to be the already calculated fractional index for the point as returned by `locateOnLine`. */ export declare function getRouteInsertPosition(map: L_2.Map, routePoints: L_2.LatLng[] | number[], trackPoints: L_2.LatLng[], point: L_2.LatLng | number): number; /** * Returns a copy of the `arr` array with `item` inserted at the index `idx`. `arr` can be an array or an array of arrays (as * returned by `getLatLngs()` on a Polyline/Polygon), and `idx` can be a number or a tuple of two numbers as returned by * `L.DraggableLines.getInsertPosition()` (and as passed along with the drag events). This method can be used to easily insert * a new point at the right position. */ export declare function insertAtPosition(arr: A, item: T, idx: number | [number, number]): A; export declare type LayerFilter = boolean | SupportedLayer | SupportedLayer[] | ((layer: SupportedLayer, ...args: Args) => boolean); /** * Finds the closest position to the given point(s) on the given polyline. * The position is given in the form of a fractional index. The index is a float somewhere between the integer index of point A * of the matching segment and the integer index of point B of the matching segment. * @param trackPoints The track points of the line. If this is an array of arrays, it is treated as a MultiLineString/Multipolygon. * @param points The point or points to locate on the line. * @param isPolygon If true, the line will be treated as a polygon, meaning that there is an additional segment between the last * and the first trackpoint (which can result in an index somewhere between trackPoints.length - 1 and trackPoints.length). * @returns If points is an array of points, returns an array matching its length and order. Otherwise a single object is returned. * If trackPoints is an array of lines, the resulting index will be a tuple where the first number is the index of the line * and the second number is the fractional index on that line. Otherwise, the fractional index is returned as a number. */ export declare function locateOnLine(map: L_2.Map, trackPoints: L_2.LatLng[], point: L_2.LatLng, isPolygon?: boolean): { idx: number; closest: L_2.LatLng; }; export declare function locateOnLine(map: L_2.Map, trackPoints: L_2.LatLng[], points: L_2.LatLng[], isPolygon?: boolean): Array<{ idx: number; closest: L_2.LatLng; }>; export declare function locateOnLine(map: L_2.Map, trackPoints: L_2.LatLng[][], point: L_2.LatLng, isPolygon?: boolean): { idx: [number, number]; closest: L_2.LatLng; }; export declare function locateOnLine(map: L_2.Map, trackPoints: L_2.LatLng[][], points: L_2.LatLng[], isPolygon?: boolean): Array<{ idx: [number, number]; closest: L_2.LatLng; }>; export declare function locateOnLine(map: L_2.Map, trackPoints: L_2.LatLng[] | L_2.LatLng[][], point: L_2.LatLng, isPolygon?: boolean): { idx: number | [number, number]; closest: L_2.LatLng; }; export declare function locateOnLine(map: L_2.Map, trackPoints: L_2.LatLng[] | L_2.LatLng[][], points: L_2.LatLng[], isPolygon?: boolean): Array<{ idx: number | [number, number]; closest: L_2.LatLng; }>; export declare function matchesLayerFilter(layer: SupportedLayer, filter: LayerFilter, ...args: NoInfer): boolean; export declare const plusIcon: Icon<{ iconUrl: string; iconSize: [number, number]; iconAnchor: [number, number]; }>; export declare type PolylineIndex = number | [number, number]; export declare function removeFromPosition(arr: A, idx: number | [number, number]): A; export declare function removePoint(layer: L_2.Polyline | L_2.Polygon, idx: number | [number, number]): void; declare type RenderPoint = { idx: PolylineIndex; closest: LatLng; }; export declare function setPoint(layer: L_2.Polyline | L_2.Polygon, point: L_2.LatLng, idx: number | [number, number], insert: boolean): void; export declare const startIcon: Icon; export declare type SupportedLayer = L_2.Polyline | L_2.Polygon; /** * Like `L.DraggableLines.insertAtPosition`, but overwrites the item at the given index instead of inserting it there. * * Returns a copy of the `arr` array with the item at index `idx` overwritten with `item`. `arr` can be an array or an array * of arrays (as returned by `getLatLngs()` on a Polyline/Polygon), and `idx` can be a number or a tuple of two numbers as * returned by `L.DraggableLines.getInsertPosition()` (and as passed along with the drag events). This method can be used * to easily update a new point at the right position while the user is dragging: */ export declare function updateAtPosition(arr: A, item: T, idx: number | [number, number]): A; export { } declare module "leaflet" { interface Polyline { hasDraggableLinesRoutePoints: () => boolean; getDraggableLinesRoutePoints: () => LatLng[] | undefined; setDraggableLinesRoutePoints: (routePoints: LatLngExpression[] | undefined) => void; } interface PolylineOptions { draggableLinesRoutePoints?: LatLngExpression[]; } interface Polyline { _draggableLines?: { dragMarkers: Marker[]; plusMarkers: Marker[]; zoomEndHandler: () => void; routePointIndexes: number[] | undefined; }; } } declare module "leaflet" { interface Handler { _map: Map; } interface Polyline { _containsPoint(p: Point): boolean; } interface Marker { _icon: HTMLElement; } namespace Draggable { const _dragging: Draggable; } namespace LineUtil { function isFlat(latlngs: LatLngExpression[] | LatLngExpression[][]): latlngs is LatLngExpression[]; function _sqClosestPointOnSegment(p: Point, p1: Point, p2: Point, sqDist?: false): Point; function _sqClosestPointOnSegment(p: Point, p1: Point, p2: Point, sqDist: true): number; } } declare module "leaflet" { interface Polyline { hasDraggableLinesRoutePoints: () => boolean; getDraggableLinesRoutePoints: () => LatLng[] | undefined; setDraggableLinesRoutePoints: (routePoints: LatLngExpression[] | undefined) => void; } interface PolylineOptions { draggableLinesRoutePoints?: LatLngExpression[]; } interface Polyline { _draggableLines?: { dragMarkers: Marker[]; plusMarkers: Marker[]; zoomEndHandler: () => void; routePointIndexes: number[] | undefined; }; } }