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.
158 lines • 6.12 kB
TypeScript
/**
* Leaflet Compatibility Adapter
* Provides a unified interface for both Leaflet v1.x and v2.x
*/
import * as L from 'leaflet';
import { LeafletVersion } from '../enums';
type UnknownRecord = Record<string, unknown>;
type UnknownFn = (...args: unknown[]) => unknown;
type AnimationFrameCallback = (time: number) => void;
export declare class LeafletAdapter {
private get version();
/**
* Creates a tile layer compatible with both Leaflet versions
*/
createTileLayer(urlTemplate: string, options?: L.TileLayerOptions): L.TileLayer;
/**
* Creates a map compatible with both Leaflet versions
*/
createMap(element: string | HTMLElement, options?: L.MapOptions): L.Map;
/**
* Creates a marker compatible with both Leaflet versions
*/
createMarker(latlng: L.LatLng, options?: L.MarkerOptions): L.Marker;
/**
* Creates a polyline compatible with both Leaflet versions
*/
createPolyline(latlngs: L.LatLng[], options?: L.PolylineOptions): L.Polyline;
/**
* Creates a polygon compatible with both Leaflet versions
*/
createPolygon(latlngs: L.LatLng[] | L.LatLng[][] | L.LatLng[][][], options?: L.PolylineOptions): L.Polygon;
/**
* Creates a div icon compatible with both Leaflet versions
*/
createDivIcon(options?: L.DivIconOptions): L.DivIcon;
/**
* Creates a LatLng object compatible with both Leaflet versions
*/
createLatLng(lat: number, lng: number, alt?: number): L.LatLng;
/**
* Creates a LatLngBounds object compatible with both Leaflet versions
*/
createLatLngBounds(corner1?: L.LatLngExpression, corner2?: L.LatLngExpression): L.LatLngBounds;
/**
* Creates a Point object compatible with both Leaflet versions
*/
createPoint(x: number, y: number, round?: boolean): L.Point;
/**
* Creates a popup compatible with both Leaflet versions
*/
createPopup(options?: L.PopupOptions, source?: L.Layer): L.Popup;
/**
* Creates a feature group compatible with both Leaflet versions
*/
createFeatureGroup(layers?: L.Layer[]): L.FeatureGroup;
/**
* Creates a layer group compatible with both Leaflet versions
*/
createLayerGroup(layers?: L.Layer[]): L.LayerGroup;
/**
* DOM utility methods compatibility
*/
domUtil: {
create: (tagName: string, className?: string, container?: HTMLElement) => HTMLElement;
addClass: (el: HTMLElement, name: string) => void;
removeClass: (el: HTMLElement, name: string) => void;
hasClass: (el: HTMLElement, name: string) => boolean;
setPosition: (el: HTMLElement, point: L.Point) => void;
getPosition: (el: HTMLElement) => L.Point;
};
/**
* DOM event methods compatibility
*/
domEvent: {
on: (obj: HTMLElement, types: string, fn: (e: Event) => void, context?: unknown) => typeof this;
off: (obj: HTMLElement, types: string, fn: (e: Event) => void, context?: unknown) => typeof this;
stopPropagation: (e: Event) => typeof this;
preventDefault: (e: Event) => typeof this;
stop: (e: Event) => typeof this;
disableClickPropagation: (el: HTMLElement) => typeof this;
disableScrollPropagation: (el: HTMLElement) => typeof this;
getMousePosition: (e: MouseEvent, container?: HTMLElement) => L.Point;
};
/**
* Utility methods compatibility
*/
util: {
extend: (dest: UnknownRecord, ...sources: UnknownRecord[]) => UnknownRecord;
bind: <T extends UnknownFn>(fn: T, obj: unknown) => T;
stamp: (obj: object) => number;
throttle: (fn: UnknownFn, time: number, context: unknown) => UnknownFn;
wrapNum: (x: number, range: number[], includeMax?: boolean) => number;
falseFn: () => boolean;
formatNum: (num: number, digits?: number) => number;
trim: (str: string) => string;
splitWords: (str: string) => string[];
setOptions: (obj: UnknownRecord, options: UnknownRecord) => UnknownRecord;
getParamString: (obj: Record<string, unknown>, existingUrl?: string, uppercase?: boolean) => string;
template: (str: string, data: UnknownRecord) => string;
isArray: (obj: unknown) => boolean;
indexOf: (array: unknown[], item: unknown) => number;
requestAnimFrame: (fn: AnimationFrameCallback, context?: unknown, immediate?: boolean) => number;
cancelAnimFrame: (id: number) => void;
};
/**
* Browser detection compatibility
*/
getBrowser(): {
readonly ie: boolean;
readonly ielt9: boolean;
readonly edge: boolean;
readonly webkit: boolean;
readonly android: boolean;
readonly android23: boolean;
readonly androidStock: boolean;
readonly opera: boolean;
readonly chrome: boolean;
readonly gecko: boolean;
readonly safari: boolean;
readonly phantom: boolean;
readonly opera12: boolean;
readonly win: boolean;
readonly ie3d: boolean;
readonly webkit3d: boolean;
readonly gecko3d: boolean;
readonly any3d: boolean;
readonly mobile: boolean;
readonly mobileWebkit: boolean;
readonly mobileWebkit3d: boolean;
readonly msPointer: boolean;
readonly pointer: boolean;
readonly touch: boolean;
readonly touchNative: boolean;
readonly mobileOpera: boolean;
readonly mobileGecko: boolean;
readonly retina: boolean;
readonly passiveEvents: boolean;
readonly canvas: boolean;
readonly svg: boolean;
readonly vml: boolean;
readonly inlineSvg: boolean;
};
/**
* Gets the current Leaflet version being used
*/
getVersion(): LeafletVersion;
/**
* Checks if we're running Leaflet v1.x
*/
isV1(): boolean;
/**
* Checks if we're running Leaflet v2.x
*/
isV2(): boolean;
}
export declare const leafletAdapter: LeafletAdapter;
export {};
//# sourceMappingURL=leaflet-adapter.d.ts.map