@florasync/leaflet-geokit 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +666 -59
- package/dist/django/index.js +9517 -0
- package/dist/django/index.js.map +1 -0
- package/dist/leaflet-geokit.es.js +2039 -1871
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +2201 -0
- package/dist/leaflet-geokit.external.es.js.map +1 -0
- package/dist/leaflet-geokit.umd.js +36 -16
- package/dist/leaflet-geokit.umd.js.map +1 -1
- package/dist/preact/index-BM2U4rKn.js +2188 -0
- package/dist/preact/index-BM2U4rKn.js.map +1 -0
- package/dist/preact/index.js +109 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/preact-bundled/index.js +9496 -0
- package/dist/preact-bundled/index.js.map +1 -0
- package/dist/react/index-BM2U4rKn.js +2188 -0
- package/dist/react/index-BM2U4rKn.js.map +1 -0
- package/dist/react/index.js +109 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react-bundled/index.js +9496 -0
- package/dist/react-bundled/index.js.map +1 -0
- package/dist/types/e2e/component.spec.d.ts +1 -0
- package/dist/types/e2e/dummy.spec.d.ts +1 -0
- package/dist/types/src/components/LeafletDrawMapElement.d.ts +94 -0
- package/dist/types/src/django/index.d.ts +35 -0
- package/dist/types/src/external.d.ts +4 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/lib/FeatureStore.d.ts +48 -0
- package/dist/types/src/lib/MapController.d.ts +116 -0
- package/dist/types/src/lib/draw/L.Draw.Cake.d.ts +9 -0
- package/dist/types/src/lib/draw/toolbar-patch.d.ts +2 -0
- package/dist/types/src/lib/layer-cake/CakeBaker.d.ts +12 -0
- package/dist/types/src/lib/layer-cake/LayerCakeManager.d.ts +29 -0
- package/dist/types/src/lib/layer-cake/bindCakeControls.d.ts +8 -0
- package/dist/types/src/lib/layer-cake/ensureCircleEditable.d.ts +2 -0
- package/dist/types/src/lib/leaflet-assets.d.ts +23 -0
- package/dist/types/src/preact/core.d.ts +36 -0
- package/dist/types/src/preact/index.d.ts +8 -0
- package/dist/types/src/preact-bundled/index.d.ts +9 -0
- package/dist/types/src/react/core.d.ts +36 -0
- package/dist/types/src/react/index.d.ts +7 -0
- package/dist/types/src/react-bundled/index.d.ts +8 -0
- package/dist/types/src/shims/ensure-element.d.ts +2 -0
- package/dist/types/src/state/types.d.ts +7 -0
- package/dist/types/src/types/events.d.ts +71 -0
- package/dist/types/src/types/public.d.ts +106 -0
- package/dist/types/src/utils/geodesic.d.ts +8 -0
- package/dist/types/src/utils/geojson.d.ts +70 -0
- package/dist/types/src/utils/leaflet-guards.d.ts +9 -0
- package/dist/types/src/utils/logger.d.ts +12 -0
- package/dist/types/src/utils/ruler.d.ts +31 -0
- package/dist/types/tests/bbox-more.spec.d.ts +1 -0
- package/dist/types/tests/component-api-more.spec.d.ts +1 -0
- package/dist/types/tests/component-delegation.spec.d.ts +1 -0
- package/dist/types/tests/component-events.spec.d.ts +1 -0
- package/dist/types/tests/component-io.spec.d.ts +1 -0
- package/dist/types/tests/django-shim.spec.d.ts +1 -0
- package/dist/types/tests/draw-cake.spec.d.ts +1 -0
- package/dist/types/tests/eachcoord.spec.d.ts +1 -0
- package/dist/types/tests/element.spec.d.ts +1 -0
- package/dist/types/tests/featureStore-more.spec.d.ts +1 -0
- package/dist/types/tests/featureStore.spec.d.ts +1 -0
- package/dist/types/tests/framework-runtime-externalization.spec.d.ts +1 -0
- package/dist/types/tests/geodesic.spec.d.ts +1 -0
- package/dist/types/tests/geojson-merge.spec.d.ts +1 -0
- package/dist/types/tests/geojson-more.spec.d.ts +1 -0
- package/dist/types/tests/geojson.spec.d.ts +1 -0
- package/dist/types/tests/layer-cake-baker.spec.d.ts +1 -0
- package/dist/types/tests/layer-cake-controls.spec.d.ts +1 -0
- package/dist/types/tests/layer-cake-editing.spec.d.ts +1 -0
- package/dist/types/tests/layer-cake-manager.spec.d.ts +1 -0
- package/dist/types/tests/leaflet-assets.spec.d.ts +1 -0
- package/dist/types/tests/leaflet-draw-circle-resize-patch.spec.d.ts +1 -0
- package/dist/types/tests/logger-more.spec.d.ts +1 -0
- package/dist/types/tests/logger.spec.d.ts +1 -0
- package/dist/types/tests/map-controller.spec.d.ts +1 -0
- package/dist/types/tests/mapcontroller-merge.spec.d.ts +1 -0
- package/dist/types/tests/preact-bundled-shim.spec.d.ts +1 -0
- package/dist/types/tests/react-bundled-shim.spec.d.ts +1 -0
- package/dist/types/tests/react-shim.spec.d.ts +1 -0
- package/dist/types/tests/ruler.spec.d.ts +1 -0
- package/dist/types/vite.config.d.ts +2 -0
- package/dist/types/vite.config.external.d.ts +2 -0
- package/dist/types/vite.config.preact-bundled.d.ts +2 -0
- package/dist/types/vite.config.preact.d.ts +2 -0
- package/dist/types/vite.config.react-bundled.d.ts +2 -0
- package/dist/types/vite.config.react.d.ts +2 -0
- package/package.json +61 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
+
import type { LeafletDrawMapElementAPI, MeasurementSystem } from "@src/types/public";
|
|
3
|
+
import { type LogLevel } from "@src/utils/logger";
|
|
4
|
+
import type * as LeafletNS from "leaflet";
|
|
5
|
+
export declare class LeafletDrawMapElement extends HTMLElement implements LeafletDrawMapElementAPI {
|
|
6
|
+
private _root;
|
|
7
|
+
private _container;
|
|
8
|
+
private _logger;
|
|
9
|
+
private _latitude;
|
|
10
|
+
private _longitude;
|
|
11
|
+
private _zoom;
|
|
12
|
+
private _minZoom?;
|
|
13
|
+
private _maxZoom?;
|
|
14
|
+
private _tileUrl;
|
|
15
|
+
private _tileAttribution?;
|
|
16
|
+
private _readOnly;
|
|
17
|
+
private _logLevel;
|
|
18
|
+
private _devOverlay;
|
|
19
|
+
private _polygonAllowIntersection;
|
|
20
|
+
private _preferCanvas;
|
|
21
|
+
private _themeUrl?;
|
|
22
|
+
private _themeCss;
|
|
23
|
+
private _themeLinkEl;
|
|
24
|
+
private _themeStyleEl;
|
|
25
|
+
private _controller;
|
|
26
|
+
private _useExternalLeaflet;
|
|
27
|
+
private _skipLeafletStyles;
|
|
28
|
+
private _leafletInstance;
|
|
29
|
+
constructor();
|
|
30
|
+
private _controlsFromAttributes;
|
|
31
|
+
private _mapConfig;
|
|
32
|
+
connectedCallback(): Promise<void>;
|
|
33
|
+
disconnectedCallback(): Promise<void>;
|
|
34
|
+
static get observedAttributes(): string[];
|
|
35
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
36
|
+
get latitude(): number;
|
|
37
|
+
set latitude(v: number);
|
|
38
|
+
get longitude(): number;
|
|
39
|
+
set longitude(v: number);
|
|
40
|
+
get zoom(): number;
|
|
41
|
+
set zoom(v: number);
|
|
42
|
+
get minZoom(): number | undefined;
|
|
43
|
+
set minZoom(v: number | undefined);
|
|
44
|
+
get maxZoom(): number | undefined;
|
|
45
|
+
set maxZoom(v: number | undefined);
|
|
46
|
+
get tileUrl(): string;
|
|
47
|
+
set tileUrl(v: string);
|
|
48
|
+
get tileAttribution(): string | undefined;
|
|
49
|
+
set tileAttribution(v: string | undefined);
|
|
50
|
+
get readOnly(): boolean;
|
|
51
|
+
set readOnly(v: boolean);
|
|
52
|
+
get logLevel(): LogLevel;
|
|
53
|
+
set logLevel(v: LogLevel);
|
|
54
|
+
get devOverlay(): boolean;
|
|
55
|
+
set devOverlay(v: boolean);
|
|
56
|
+
get preferCanvas(): boolean;
|
|
57
|
+
set preferCanvas(v: boolean);
|
|
58
|
+
get useExternalLeaflet(): boolean;
|
|
59
|
+
set useExternalLeaflet(v: boolean);
|
|
60
|
+
get skipLeafletStyles(): boolean;
|
|
61
|
+
set skipLeafletStyles(v: boolean);
|
|
62
|
+
get leafletInstance(): typeof LeafletNS | undefined;
|
|
63
|
+
set leafletInstance(v: typeof LeafletNS | undefined);
|
|
64
|
+
get themeCss(): string;
|
|
65
|
+
set themeCss(v: string);
|
|
66
|
+
getGeoJSON(): Promise<FeatureCollection>;
|
|
67
|
+
loadGeoJSON(fc: FeatureCollection): Promise<void>;
|
|
68
|
+
clearLayers(): Promise<void>;
|
|
69
|
+
addFeatures(fc: FeatureCollection): Promise<string[]>;
|
|
70
|
+
updateFeature(id: string, feature: Feature): Promise<void>;
|
|
71
|
+
removeFeature(id: string): Promise<void>;
|
|
72
|
+
fitBoundsToData(padding?: number): Promise<void>;
|
|
73
|
+
fitBounds(bounds: [[number, number], [number, number]], padding?: number): Promise<void>;
|
|
74
|
+
setView(lat: number, lng: number, zoom?: number): Promise<void>;
|
|
75
|
+
exportGeoJSON(): Promise<FeatureCollection>;
|
|
76
|
+
/**
|
|
77
|
+
* Merge all visible polygon layers into a single polygon.
|
|
78
|
+
* This removes the original polygon features and adds a new merged feature.
|
|
79
|
+
*
|
|
80
|
+
* @param options Optional configuration for the merge operation
|
|
81
|
+
* @returns Promise resolving to the ID of the newly created merged feature, or null if no polygons to merge
|
|
82
|
+
*/
|
|
83
|
+
mergePolygons(options?: {
|
|
84
|
+
properties?: Record<string, any>;
|
|
85
|
+
}): Promise<string | null>;
|
|
86
|
+
setMeasurementUnits(system: MeasurementSystem): Promise<void>;
|
|
87
|
+
loadGeoJSONFromUrl(url: string): Promise<void>;
|
|
88
|
+
loadGeoJSONFromText(text: string): Promise<void>;
|
|
89
|
+
private _currentConfig;
|
|
90
|
+
private _applyThemeStyles;
|
|
91
|
+
private _reflect;
|
|
92
|
+
private _booleanReflect;
|
|
93
|
+
private _coerceNumber;
|
|
94
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "@src/index";
|
|
2
|
+
import type { LeafletDrawMapElement } from "@src/components/LeafletDrawMapElement";
|
|
3
|
+
export type DjangoShimPhase = "mount" | "parse" | "sync";
|
|
4
|
+
export interface DjangoShimErrorContext {
|
|
5
|
+
phase: DjangoShimPhase;
|
|
6
|
+
textarea: HTMLTextAreaElement;
|
|
7
|
+
element?: LeafletDrawMapElement;
|
|
8
|
+
}
|
|
9
|
+
export interface DjangoShimHandle {
|
|
10
|
+
textarea: HTMLTextAreaElement;
|
|
11
|
+
element: LeafletDrawMapElement;
|
|
12
|
+
container: HTMLDivElement;
|
|
13
|
+
sync: () => Promise<void>;
|
|
14
|
+
destroy: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface DjangoShimOptions {
|
|
17
|
+
selector?: string;
|
|
18
|
+
height?: number | string;
|
|
19
|
+
attributePrefix?: string;
|
|
20
|
+
onError?: (error: Error, context: DjangoShimErrorContext) => void;
|
|
21
|
+
onInit?: (handle: DjangoShimHandle) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Programmatic attributes to apply to the <leaflet-geokit> element.
|
|
24
|
+
* These take precedence over textarea data attributes.
|
|
25
|
+
*/
|
|
26
|
+
elementAttributes?: Record<string, string | number | boolean>;
|
|
27
|
+
}
|
|
28
|
+
export declare function initDjangoGeokit(selectorOrOptions?: string | DjangoShimOptions, maybeOptions?: DjangoShimOptions): DjangoShimHandle[];
|
|
29
|
+
declare global {
|
|
30
|
+
interface Window {
|
|
31
|
+
GeoKitDjango?: {
|
|
32
|
+
init: typeof initDjangoGeokit;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
+
import { type BoundsPair } from "@src/utils/geojson";
|
|
3
|
+
import { type Logger } from "@src/utils/logger";
|
|
4
|
+
/**
|
|
5
|
+
* FeatureStore
|
|
6
|
+
* - Maintains a stable, id-centric in-memory FeatureCollection
|
|
7
|
+
* - IDs are sourced from feature.id, feature.properties.id, or generated (uuid v4)
|
|
8
|
+
* - Provides CRUD and export helpers
|
|
9
|
+
*
|
|
10
|
+
* Note: Leaflet layer bindings will be handled by the controller; this store is map-agnostic.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FeatureStore {
|
|
13
|
+
private log;
|
|
14
|
+
private features;
|
|
15
|
+
constructor(logger?: Logger);
|
|
16
|
+
size(): number;
|
|
17
|
+
has(id: string): boolean;
|
|
18
|
+
get(id: string): Feature | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Add features to the store; returns the assigned/normalized ids in order.
|
|
21
|
+
*/
|
|
22
|
+
add(fc: FeatureCollection): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Update a feature by id. If the feature does not exist, this is a no-op.
|
|
25
|
+
* The provided feature will overwrite the stored one with the given id.
|
|
26
|
+
*/
|
|
27
|
+
update(id: string, feature: Feature): void;
|
|
28
|
+
/**
|
|
29
|
+
* Remove a feature by id. No-op if missing.
|
|
30
|
+
*/
|
|
31
|
+
remove(id: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Clear all features.
|
|
34
|
+
*/
|
|
35
|
+
clear(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Export snapshot as FeatureCollection.
|
|
38
|
+
*/
|
|
39
|
+
toFeatureCollection(): FeatureCollection;
|
|
40
|
+
/**
|
|
41
|
+
* Compute bounds for current data as [[south, west], [north, east]] or null if empty.
|
|
42
|
+
*/
|
|
43
|
+
bounds(): BoundsPair | null;
|
|
44
|
+
/**
|
|
45
|
+
* Ensure the feature has an id; returns the resolved id.
|
|
46
|
+
*/
|
|
47
|
+
private ensureId;
|
|
48
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as BundledL from "leaflet";
|
|
2
|
+
import "leaflet-draw";
|
|
3
|
+
import "leaflet-ruler";
|
|
4
|
+
import type { Feature, FeatureCollection } from "geojson";
|
|
5
|
+
import type { DrawControlsConfig, MapConfig, MeasurementSystem } from "@src/types/public";
|
|
6
|
+
import { type Logger } from "@src/utils/logger";
|
|
7
|
+
export interface MapControllerCallbacks {
|
|
8
|
+
onReady?: (detail: {
|
|
9
|
+
bounds?: [[number, number], [number, number]];
|
|
10
|
+
}) => void;
|
|
11
|
+
onCreated?: (detail: {
|
|
12
|
+
id: string;
|
|
13
|
+
layerType: "polygon" | "polyline" | "rectangle" | "circle" | "marker";
|
|
14
|
+
geoJSON: Feature;
|
|
15
|
+
}) => void;
|
|
16
|
+
onEdited?: (detail: {
|
|
17
|
+
ids: string[];
|
|
18
|
+
geoJSON: FeatureCollection;
|
|
19
|
+
}) => void;
|
|
20
|
+
onDeleted?: (detail: {
|
|
21
|
+
ids: string[];
|
|
22
|
+
geoJSON: FeatureCollection;
|
|
23
|
+
}) => void;
|
|
24
|
+
onError?: (detail: {
|
|
25
|
+
message: string;
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
}) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface MapControllerOptions {
|
|
30
|
+
container: HTMLElement;
|
|
31
|
+
map: MapConfig;
|
|
32
|
+
controls: DrawControlsConfig;
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
logger?: Logger;
|
|
35
|
+
callbacks?: MapControllerCallbacks;
|
|
36
|
+
/** Optional injected Leaflet namespace to use instead of bundled import. */
|
|
37
|
+
leaflet?: typeof BundledL;
|
|
38
|
+
/** Prefer external Leaflet if available (falls back to bundled if missing/invalid). */
|
|
39
|
+
useExternalLeaflet?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* MapController: initializes Leaflet map + Draw, bridges events, and manages data via FeatureStore.
|
|
43
|
+
*/
|
|
44
|
+
export declare class MapController {
|
|
45
|
+
private container;
|
|
46
|
+
private logger;
|
|
47
|
+
private options;
|
|
48
|
+
private L;
|
|
49
|
+
private store;
|
|
50
|
+
private map;
|
|
51
|
+
private drawnItems;
|
|
52
|
+
private drawControl;
|
|
53
|
+
private rulerControl;
|
|
54
|
+
private measurementControl;
|
|
55
|
+
private measurementSystem;
|
|
56
|
+
private measurementModalOverlay;
|
|
57
|
+
private measurementModalDialog;
|
|
58
|
+
private measurementModalRadios;
|
|
59
|
+
private measurementModalKeydownHandler;
|
|
60
|
+
private detachPolygonFinishPatch;
|
|
61
|
+
private vertexMenuEl;
|
|
62
|
+
private vertexMenuCleanup;
|
|
63
|
+
private activeCakeSession;
|
|
64
|
+
constructor(opts: MapControllerOptions);
|
|
65
|
+
private resolveLeaflet;
|
|
66
|
+
init(): Promise<void>;
|
|
67
|
+
destroy(): Promise<void>;
|
|
68
|
+
getGeoJSON(): Promise<FeatureCollection>;
|
|
69
|
+
loadGeoJSON(fc: FeatureCollection, fitToData?: boolean): Promise<void>;
|
|
70
|
+
clearLayers(): Promise<void>;
|
|
71
|
+
addFeatures(fc: FeatureCollection): Promise<string[]>;
|
|
72
|
+
updateFeature(id: string, feature: Feature): Promise<void>;
|
|
73
|
+
removeFeature(id: string): Promise<void>;
|
|
74
|
+
fitBoundsToData(paddingRatio?: number): Promise<void>;
|
|
75
|
+
fitBounds(boundsTuple: [[number, number], [number, number]], paddingRatio?: number): Promise<void>;
|
|
76
|
+
setView(lat: number, lng: number, zoom?: number): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Merge all visible polygon features into a single polygon feature.
|
|
79
|
+
* This removes the original features and adds a new feature with the merged geometry.
|
|
80
|
+
*
|
|
81
|
+
* @param options Optional configuration for the merge operation
|
|
82
|
+
* @returns The ID of the newly created merged feature, or null if no polygons to merge
|
|
83
|
+
*/
|
|
84
|
+
mergeVisiblePolygons(options?: {
|
|
85
|
+
/** Properties to apply to the merged feature (defaults to properties from first polygon) */
|
|
86
|
+
properties?: Record<string, any>;
|
|
87
|
+
}): Promise<string | null>;
|
|
88
|
+
setRulerUnits(system: MeasurementSystem): void;
|
|
89
|
+
private buildDrawOptions;
|
|
90
|
+
private applyLayerCakeToolbarIcon;
|
|
91
|
+
private addRulerControl;
|
|
92
|
+
private installRulerPrecisionPatch;
|
|
93
|
+
private rebuildRulerControl;
|
|
94
|
+
private installMeasurementSettingsControl;
|
|
95
|
+
private ensureMeasurementModal;
|
|
96
|
+
private toggleMeasurementModal;
|
|
97
|
+
private syncMeasurementModalState;
|
|
98
|
+
private removeMeasurementModal;
|
|
99
|
+
private attachMeasurementModalKeydown;
|
|
100
|
+
private detachMeasurementModalKeydown;
|
|
101
|
+
/**
|
|
102
|
+
* Workaround: In some environments (notably within Shadow DOM), clicking the first vertex
|
|
103
|
+
* to close a polygon can be unreliable due to event retargeting/hit testing.
|
|
104
|
+
* This patch listens for map clicks while the polygon draw handler is enabled and,
|
|
105
|
+
* if the click is within a small pixel radius of the first vertex, it triggers finishShape().
|
|
106
|
+
*/
|
|
107
|
+
private installPolygonFinishPatch;
|
|
108
|
+
private patchLeafletDrawBugs;
|
|
109
|
+
private bindDrawEvents;
|
|
110
|
+
private _error;
|
|
111
|
+
private installVertexContextMenu;
|
|
112
|
+
private openVertexMenu;
|
|
113
|
+
private showVertexMenu;
|
|
114
|
+
private findNearestVertex;
|
|
115
|
+
private deleteVertex;
|
|
116
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as L from "leaflet";
|
|
2
|
+
declare const DrawCake_base: any;
|
|
3
|
+
export declare class DrawCake extends DrawCake_base {
|
|
4
|
+
static TYPE: string;
|
|
5
|
+
constructor(map: L.Map, options?: L.DrawOptions.CircleOptions);
|
|
6
|
+
addHooks(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function ensureDrawCakeRegistered(Lns: typeof L): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface CircleLike {
|
|
2
|
+
getLatLng(): {
|
|
3
|
+
lat: number;
|
|
4
|
+
lng: number;
|
|
5
|
+
};
|
|
6
|
+
getRadius(): number;
|
|
7
|
+
}
|
|
8
|
+
export interface CakeLayerOptions {
|
|
9
|
+
circles: CircleLike[];
|
|
10
|
+
steps?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function bakeLayerCake(options: CakeLayerOptions): GeoJSON.FeatureCollection;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as L from "leaflet";
|
|
2
|
+
import type { MeasurementSystem } from "@src/types/public";
|
|
3
|
+
export declare class LayerCakeManager {
|
|
4
|
+
private map;
|
|
5
|
+
private layers;
|
|
6
|
+
private controlsGroup;
|
|
7
|
+
private onSave;
|
|
8
|
+
private sessionId;
|
|
9
|
+
private baseCircleOptions;
|
|
10
|
+
private detachMapListeners;
|
|
11
|
+
private renderScheduled;
|
|
12
|
+
private measurementSystem;
|
|
13
|
+
constructor(map: L.Map, initialCircle: L.Circle, onSave: (geojson: GeoJSON.FeatureCollection) => void, measurementSystem?: MeasurementSystem);
|
|
14
|
+
private installEditEventBridges;
|
|
15
|
+
private requestRenderControls;
|
|
16
|
+
private addLayer;
|
|
17
|
+
addRing(): void;
|
|
18
|
+
save(): void;
|
|
19
|
+
private getLargestCircle;
|
|
20
|
+
private syncCenters;
|
|
21
|
+
/**
|
|
22
|
+
* Update the label for the active circle being resized.
|
|
23
|
+
* Shows both total radius and delta (ring width) from the next smaller circle.
|
|
24
|
+
* Positions the tooltip on the left side to avoid toolbar interference.
|
|
25
|
+
*/
|
|
26
|
+
private updateLabels;
|
|
27
|
+
private renderControls;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inject Leaflet and Leaflet.draw CSS into the given ShadowRoot.
|
|
3
|
+
* Idempotent: does nothing if already injected for this root.
|
|
4
|
+
*/
|
|
5
|
+
export declare function injectLeafletStyles(root: ShadowRoot): void;
|
|
6
|
+
/**
|
|
7
|
+
* Inject only project-specific style overrides that must exist even when
|
|
8
|
+
* consumers provide external Leaflet CSS.
|
|
9
|
+
* Idempotent: does nothing if already injected for this root.
|
|
10
|
+
*/
|
|
11
|
+
export declare function injectLeafletCustomStyles(root: ShadowRoot): void;
|
|
12
|
+
/**
|
|
13
|
+
* Ensure Leaflet default marker icons resolve via the bundler.
|
|
14
|
+
* Safe to call multiple times.
|
|
15
|
+
*/
|
|
16
|
+
export declare function configureLeafletDefaultIcons(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Conditional helper: apply styles and icon wiring only if not skipped.
|
|
19
|
+
*/
|
|
20
|
+
export declare function applyLeafletStylingIfNeeded(options: {
|
|
21
|
+
root: ShadowRoot;
|
|
22
|
+
skipStyles?: boolean;
|
|
23
|
+
}): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { LeafletDrawMapElement } from "@src/components/LeafletDrawMapElement";
|
|
2
|
+
type Primitive = string | number | boolean | null | undefined;
|
|
3
|
+
type LeafletMode = "external" | "bundled";
|
|
4
|
+
export interface PreactLeafletGeoKitProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: string | Record<string, string | number>;
|
|
7
|
+
/**
|
|
8
|
+
* HTML attributes to apply to <leaflet-geokit>.
|
|
9
|
+
* Boolean true => present attribute, false => removed.
|
|
10
|
+
*/
|
|
11
|
+
attributes?: Record<string, Primitive>;
|
|
12
|
+
/**
|
|
13
|
+
* Override the default entrypoint mode:
|
|
14
|
+
* - /preact defaults to external
|
|
15
|
+
* - /preact-bundled defaults to bundled
|
|
16
|
+
*/
|
|
17
|
+
externalLeaflet?: boolean;
|
|
18
|
+
/** Optional explicit Leaflet namespace (window.L equivalent). */
|
|
19
|
+
leafletInstance?: any;
|
|
20
|
+
/** Initial GeoJSON text to load once on ready. */
|
|
21
|
+
initialGeoJSONText?: string;
|
|
22
|
+
/** Called whenever draw/edit/delete/merge occurs, with latest serialized FeatureCollection. */
|
|
23
|
+
onChangeText?: (text: string) => void;
|
|
24
|
+
/** Called with parsed FeatureCollection after sync, if parsing is desired by host. */
|
|
25
|
+
onChangeGeoJSON?: (geoJSON: unknown) => void;
|
|
26
|
+
/** Called if sync/load operations fail. */
|
|
27
|
+
onError?: (error: Error) => void;
|
|
28
|
+
/** Access underlying custom element instance. */
|
|
29
|
+
onReady?: (element: LeafletDrawMapElement) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createPreactLeafletGeoKit(defaultMode: LeafletMode): (props: PreactLeafletGeoKitProps) => import("preact").VNode<import("preact").Attributes & {
|
|
32
|
+
ref: import("preact/hooks").MutableRef<LeafletDrawMapElement | null>;
|
|
33
|
+
className: string | undefined;
|
|
34
|
+
style: string;
|
|
35
|
+
}>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PreactLeafletGeoKitProps } from "@src/preact/core";
|
|
2
|
+
export type { PreactLeafletGeoKitProps };
|
|
3
|
+
export declare const PreactLeafletGeoKit: (props: PreactLeafletGeoKitProps) => import("preact").VNode<import("preact").Attributes & {
|
|
4
|
+
ref: import("preact/hooks").MutableRef<import("..").LeafletDrawMapElement | null>;
|
|
5
|
+
className: string | undefined;
|
|
6
|
+
style: string;
|
|
7
|
+
}>;
|
|
8
|
+
export default PreactLeafletGeoKit;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "@src/index";
|
|
2
|
+
import { type PreactLeafletGeoKitProps } from "@src/preact/core";
|
|
3
|
+
export type { PreactLeafletGeoKitProps };
|
|
4
|
+
export declare const PreactLeafletGeoKit: (props: PreactLeafletGeoKitProps) => import("preact").VNode<import("preact").Attributes & {
|
|
5
|
+
ref: import("preact/hooks").MutableRef<import("@src/index").LeafletDrawMapElement | null>;
|
|
6
|
+
className: string | undefined;
|
|
7
|
+
style: string;
|
|
8
|
+
}>;
|
|
9
|
+
export default PreactLeafletGeoKit;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { LeafletDrawMapElement } from "@src/components/LeafletDrawMapElement";
|
|
3
|
+
type Primitive = string | number | boolean | null | undefined;
|
|
4
|
+
type LeafletMode = "external" | "bundled";
|
|
5
|
+
export interface ReactLeafletGeoKitProps {
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: string | Record<string, string | number>;
|
|
8
|
+
/**
|
|
9
|
+
* HTML attributes to apply to <leaflet-geokit>.
|
|
10
|
+
* Boolean true => present attribute, false => removed.
|
|
11
|
+
*/
|
|
12
|
+
attributes?: Record<string, Primitive>;
|
|
13
|
+
/**
|
|
14
|
+
* Override the default entrypoint mode:
|
|
15
|
+
* - /react defaults to external
|
|
16
|
+
* - /react-bundled defaults to bundled
|
|
17
|
+
*/
|
|
18
|
+
externalLeaflet?: boolean;
|
|
19
|
+
/** Optional explicit Leaflet namespace (window.L equivalent). */
|
|
20
|
+
leafletInstance?: any;
|
|
21
|
+
/** Initial GeoJSON text to load once on ready. */
|
|
22
|
+
initialGeoJSONText?: string;
|
|
23
|
+
/** Called whenever draw/edit/delete/merge occurs, with latest serialized FeatureCollection. */
|
|
24
|
+
onChangeText?: (text: string) => void;
|
|
25
|
+
/** Called with parsed FeatureCollection after sync, if parsing is desired by host. */
|
|
26
|
+
onChangeGeoJSON?: (geoJSON: unknown) => void;
|
|
27
|
+
/** Called if sync/load operations fail. */
|
|
28
|
+
onError?: (error: Error) => void;
|
|
29
|
+
/** Access underlying custom element instance. */
|
|
30
|
+
onReady?: (element: LeafletDrawMapElement) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createReactLeafletGeoKit(defaultMode: LeafletMode): (props: ReactLeafletGeoKitProps) => React.ReactElement<{
|
|
33
|
+
ref: React.MutableRefObject<LeafletDrawMapElement | null>;
|
|
34
|
+
className: string | undefined;
|
|
35
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactLeafletGeoKitProps } from "@src/react/core";
|
|
2
|
+
export type { ReactLeafletGeoKitProps };
|
|
3
|
+
export declare const ReactLeafletGeoKit: (props: ReactLeafletGeoKitProps) => import("react").ReactElement<{
|
|
4
|
+
ref: import("react").MutableRefObject<import("..").LeafletDrawMapElement | null>;
|
|
5
|
+
className: string | undefined;
|
|
6
|
+
}, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
export default ReactLeafletGeoKit;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "@src/index";
|
|
2
|
+
import { type ReactLeafletGeoKitProps } from "@src/react/core";
|
|
3
|
+
export type { ReactLeafletGeoKitProps };
|
|
4
|
+
export declare const ReactLeafletGeoKit: (props: ReactLeafletGeoKitProps) => import("react").ReactElement<{
|
|
5
|
+
ref: import("react").MutableRefObject<import("@src/index").LeafletDrawMapElement | null>;
|
|
6
|
+
className: string | undefined;
|
|
7
|
+
}, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
export default ReactLeafletGeoKit;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
+
/**
|
|
3
|
+
* Details for the 'leaflet-draw:ready' event.
|
|
4
|
+
* bounds: optional southwest/northeast LatLng pairs.
|
|
5
|
+
*/
|
|
6
|
+
export interface ReadyEventDetail {
|
|
7
|
+
bounds?: [[number, number], [number, number]];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Details for the 'leaflet-draw:created' event.
|
|
11
|
+
* id: the stable feature id assigned by the FeatureStore.
|
|
12
|
+
*/
|
|
13
|
+
export interface CreatedEventDetail {
|
|
14
|
+
id: string;
|
|
15
|
+
layerType: "polygon" | "polyline" | "rectangle" | "circle" | "marker";
|
|
16
|
+
geoJSON: Feature;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Details for the 'leaflet-draw:edited' event.
|
|
20
|
+
* ids: array of feature ids that were edited.
|
|
21
|
+
*/
|
|
22
|
+
export interface EditedEventDetail {
|
|
23
|
+
ids: string[];
|
|
24
|
+
geoJSON: FeatureCollection;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Details for the 'leaflet-draw:deleted' event.
|
|
28
|
+
* ids: array of feature ids that were deleted.
|
|
29
|
+
*/
|
|
30
|
+
export interface DeletedEventDetail {
|
|
31
|
+
ids: string[];
|
|
32
|
+
geoJSON: FeatureCollection;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Details for error events emitted as 'leaflet-draw:error'.
|
|
36
|
+
*/
|
|
37
|
+
export interface ErrorEventDetail {
|
|
38
|
+
message: string;
|
|
39
|
+
cause?: unknown;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Details for 'leaflet-draw:ingest' event. Fired before data is added to the map.
|
|
43
|
+
* Listeners may mutate detail.fc to transform incoming data (e.g., flatten MultiPolygon).
|
|
44
|
+
*/
|
|
45
|
+
export interface IngestEventDetail {
|
|
46
|
+
fc: FeatureCollection;
|
|
47
|
+
mode: "load" | "add";
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Details for 'leaflet-draw:export' event.
|
|
51
|
+
*/
|
|
52
|
+
export interface ExportEventDetail {
|
|
53
|
+
geoJSON: FeatureCollection;
|
|
54
|
+
featureCount: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Event name constants for convenience (non-enforced).
|
|
58
|
+
*/
|
|
59
|
+
export declare const DrawEvent: {
|
|
60
|
+
readonly Ready: "leaflet-draw:ready";
|
|
61
|
+
readonly Created: "leaflet-draw:created";
|
|
62
|
+
readonly Edited: "leaflet-draw:edited";
|
|
63
|
+
readonly Deleted: "leaflet-draw:deleted";
|
|
64
|
+
readonly Error: "leaflet-draw:error";
|
|
65
|
+
readonly Ingest: "leaflet-draw:ingest";
|
|
66
|
+
readonly Export: "leaflet-draw:export";
|
|
67
|
+
readonly DrawStart: "leaflet-draw:drawstart";
|
|
68
|
+
readonly DrawStop: "leaflet-draw:drawstop";
|
|
69
|
+
readonly EditStart: "leaflet-draw:editstart";
|
|
70
|
+
readonly EditStop: "leaflet-draw:editstop";
|
|
71
|
+
};
|