UNPKG

leaflet-polydraw

Version:

Advanced Leaflet plugin for freehand polygon drawing, with smart merging and powerful editing tools. Compatible with both Leaflet v1.x and v2.x.

71 lines 2.33 kB
/** * Event Compatibility Adapter * Handles differences in event systems between Leaflet v1.x and v2.x */ import type * as L from 'leaflet'; type TouchLike = { clientX: number; clientY: number; }; type LeafletLikeEvent = { layer?: unknown; propagatedFrom?: unknown; type?: string; _isPointerEvent?: boolean; latlng?: L.LatLng; touches?: ArrayLike<TouchLike>; pointerType?: string; isPrimary?: boolean; clientX?: number; clientY?: number; cancelable?: boolean; preventDefault?: () => void; stopPropagation?: () => void; }; type LeafletMapLike = { getContainer: () => HTMLElement; containerPointToLatLng: (point: [number, number]) => L.LatLng; }; export declare class EventAdapter { /** * Normalizes events to handle differences between v1 and v2 * @param event - The event to normalize * @returns The normalized event */ static normalizeEvent(event: LeafletLikeEvent): LeafletLikeEvent; /** * Gets the appropriate event name for the current Leaflet version * @param eventName - The base event name * @returns The version-appropriate event name */ static getEventName(eventName: string): string; /** * Checks if pointer events are supported/preferred * @returns true if pointer events should be used */ static shouldUsePointerEvents(): boolean; /** * Extracts coordinates from various event types (mouse, touch, pointer) * @param event - The event to extract coordinates from * @param map - The map instance for coordinate conversion * @returns The LatLng coordinates or null if not available */ static extractCoordinates(event: LeafletLikeEvent, map: LeafletMapLike): L.LatLng | null; /** * Checks if an event should be prevented from default behavior * @param event - The event to check * @returns true if preventDefault should be called */ static shouldPreventDefault(event: LeafletLikeEvent): boolean; /** * Gets the appropriate event listener names for the current version * @returns Object with event names for different actions */ static getEventNames(): { start: string[]; move: string[]; end: string[]; }; } export {}; //# sourceMappingURL=event-adapter.d.ts.map