@florasync/leaflet-geokit 0.8.1 → 0.8.2
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 +7 -0
- package/README.md +109 -64
- package/dist/django/index.js +3409 -2913
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +3329 -2844
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +1385 -900
- package/dist/leaflet-geokit.external.es.js.map +1 -1
- package/dist/leaflet-geokit.umd.js +16 -16
- package/dist/leaflet-geokit.umd.js.map +1 -1
- package/dist/preact/{index-x8CrGR_z.js → index-DCGBWrrm.js} +1368 -870
- package/dist/preact/index-DCGBWrrm.js.map +1 -0
- package/dist/preact/index.js +1 -1
- package/dist/preact-bundled/index.js +3480 -2982
- package/dist/preact-bundled/index.js.map +1 -1
- package/dist/react/{index-x8CrGR_z.js → index-DCGBWrrm.js} +1368 -870
- package/dist/react/index-DCGBWrrm.js.map +1 -0
- package/dist/react/index.js +1 -1
- package/dist/react-bundled/index.js +2544 -2046
- package/dist/react-bundled/index.js.map +1 -1
- package/dist/types/components/LeafletDrawMapElement.d.ts +17 -4
- package/dist/types/lib/MapController.d.ts +9 -5
- package/dist/types/types/events.d.ts +34 -6
- package/dist/types/types/public.d.ts +16 -5
- package/dist/types/utils/geojson.d.ts +10 -0
- package/package.json +1 -1
- package/dist/preact/index-x8CrGR_z.js.map +0 -1
- package/dist/react/index-x8CrGR_z.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
-
import type { LeafletDrawMapElementAPI, IntegratedToolEventEmitter, IntegratedToolHooks, MarkerIconConfig, MeasurementSystem, ToolButtonConfig, ToolButtonName, ToolToolbarGroupConfig, ToolTriggerOptions } from "../types/public";
|
|
2
|
+
import type { GeoJSONImportOptions, GeoJSONExportOptions, LeafletDrawMapElementAPI, IntegratedToolEventEmitter, IntegratedToolHooks, MarkerIconConfig, MeasurementSystem, ToolButtonConfig, ToolButtonName, ToolToolbarGroupConfig, ToolTriggerOptions } from "../types/public";
|
|
3
|
+
import { type StatusEventDetail } from "../types/events";
|
|
3
4
|
import { type LogLevel } from "../utils/logger";
|
|
4
5
|
import type * as LeafletNS from "leaflet";
|
|
5
6
|
export declare class LeafletDrawMapElement extends HTMLElement implements LeafletDrawMapElementAPI {
|
|
@@ -35,6 +36,7 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
35
36
|
private _markerIconConfig;
|
|
36
37
|
private _toolButtonConfig;
|
|
37
38
|
private _toolbarGroups;
|
|
39
|
+
private _status;
|
|
38
40
|
private _externalToolTriggerListener;
|
|
39
41
|
private _externalToolDeactivateListener;
|
|
40
42
|
constructor();
|
|
@@ -72,6 +74,7 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
72
74
|
set tileStyle(v: string | undefined);
|
|
73
75
|
get apiKey(): string | undefined;
|
|
74
76
|
set apiKey(v: string | undefined);
|
|
77
|
+
get status(): StatusEventDetail;
|
|
75
78
|
get tileAttribution(): string | undefined;
|
|
76
79
|
set tileAttribution(v: string | undefined);
|
|
77
80
|
get readOnly(): boolean;
|
|
@@ -101,6 +104,7 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
101
104
|
get themeCss(): string;
|
|
102
105
|
set themeCss(v: string);
|
|
103
106
|
getGeoJSON(): Promise<FeatureCollection>;
|
|
107
|
+
importGeoJSON(fc: FeatureCollection, options?: GeoJSONImportOptions): Promise<string[]>;
|
|
104
108
|
loadGeoJSON(fc: FeatureCollection): Promise<void>;
|
|
105
109
|
clearLayers(): Promise<void>;
|
|
106
110
|
addFeatures(fc: FeatureCollection): Promise<string[]>;
|
|
@@ -109,7 +113,7 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
109
113
|
fitBoundsToData(padding?: number): Promise<void>;
|
|
110
114
|
fitBounds(bounds: [[number, number], [number, number]], padding?: number): Promise<void>;
|
|
111
115
|
setView(lat: number, lng: number, zoom?: number): Promise<void>;
|
|
112
|
-
exportGeoJSON(): Promise<FeatureCollection>;
|
|
116
|
+
exportGeoJSON(options?: GeoJSONExportOptions): Promise<FeatureCollection>;
|
|
113
117
|
/**
|
|
114
118
|
* Merge all visible polygon layers into a single polygon.
|
|
115
119
|
* This removes the original polygon features and adds a new merged feature.
|
|
@@ -124,11 +128,20 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
124
128
|
activateTool(tool: ToolButtonName, options?: ToolTriggerOptions): Promise<boolean>;
|
|
125
129
|
triggerTool(tool: ToolButtonName, options?: ToolTriggerOptions): Promise<boolean>;
|
|
126
130
|
deactivateTool(options?: ToolTriggerOptions): Promise<boolean>;
|
|
127
|
-
loadGeoJSONFromUrl(url: string): Promise<void>;
|
|
128
|
-
loadGeoJSONFromText(text: string): Promise<void>;
|
|
131
|
+
loadGeoJSONFromUrl(url: string, options?: GeoJSONImportOptions): Promise<void>;
|
|
132
|
+
loadGeoJSONFromText(text: string, options?: GeoJSONImportOptions): Promise<void>;
|
|
133
|
+
private _setImportLoadingStatus;
|
|
134
|
+
private _performImport;
|
|
135
|
+
private _importWithController;
|
|
136
|
+
private _exportWithController;
|
|
129
137
|
private _currentConfig;
|
|
130
138
|
private _applyThemeStyles;
|
|
131
139
|
private _emitToolTriggerResult;
|
|
140
|
+
private _syncStatusFromController;
|
|
141
|
+
private _emitError;
|
|
142
|
+
private _emitDiagnostic;
|
|
143
|
+
private _setStatus;
|
|
144
|
+
private _cloneStatus;
|
|
132
145
|
private _syncApiKeyFromAttributes;
|
|
133
146
|
private _normalizeText;
|
|
134
147
|
private _resolveTileProviderErrorCode;
|
|
@@ -2,7 +2,8 @@ import * as BundledL from "leaflet";
|
|
|
2
2
|
import "leaflet-draw";
|
|
3
3
|
import "leaflet-ruler";
|
|
4
4
|
import type { Feature, FeatureCollection } from "geojson";
|
|
5
|
-
import type { DrawControlsConfig, MapConfig, MeasurementSystem, IntegratedToolEventEmitter, IntegratedToolHooks, ToolButtonConfig, ToolButtonName, ToolToolbarGroupConfig, ToolTriggerEventDetail, ToolTriggerOptions } from "../types/public";
|
|
5
|
+
import type { DrawControlsConfig, GeoJSONExportOptions, GeoJSONImportOptions, MapConfig, MeasurementSystem, IntegratedToolEventEmitter, IntegratedToolHooks, ToolButtonConfig, ToolButtonName, ToolToolbarGroupConfig, ToolTriggerEventDetail, ToolTriggerOptions } from "../types/public";
|
|
6
|
+
import type { ErrorEventDetail } from "../types/events";
|
|
6
7
|
import { type Logger } from "../utils/logger";
|
|
7
8
|
import { type NormalizedMarkerIconConfig } from "../lib/marker-icons";
|
|
8
9
|
import type { TileURLTemplate } from "../lib/TileProviderFactory";
|
|
@@ -23,12 +24,13 @@ export interface MapControllerCallbacks {
|
|
|
23
24
|
ids: string[];
|
|
24
25
|
geoJSON: FeatureCollection;
|
|
25
26
|
}) => void;
|
|
26
|
-
onError?: (detail:
|
|
27
|
-
message: string;
|
|
28
|
-
cause?: unknown;
|
|
29
|
-
}) => void;
|
|
27
|
+
onError?: (detail: ErrorEventDetail) => void;
|
|
30
28
|
onTileError?: (error: unknown) => void;
|
|
31
29
|
onToolTrigger?: (detail: ToolTriggerEventDetail) => void;
|
|
30
|
+
onSaved?: (detail: {
|
|
31
|
+
geoJSON: FeatureCollection;
|
|
32
|
+
featureCount: number;
|
|
33
|
+
}) => void;
|
|
32
34
|
}
|
|
33
35
|
export interface MapControllerOptions {
|
|
34
36
|
container: HTMLElement;
|
|
@@ -105,6 +107,8 @@ export declare class MapController {
|
|
|
105
107
|
init(): Promise<void>;
|
|
106
108
|
destroy(): Promise<void>;
|
|
107
109
|
getGeoJSON(): Promise<FeatureCollection>;
|
|
110
|
+
exportGeoJSON(options?: GeoJSONExportOptions): Promise<FeatureCollection>;
|
|
111
|
+
importGeoJSON(fc: FeatureCollection, options?: GeoJSONImportOptions): Promise<string[]>;
|
|
108
112
|
loadGeoJSON(fc: FeatureCollection, fitToData?: boolean): Promise<void>;
|
|
109
113
|
clearLayers(): Promise<void>;
|
|
110
114
|
addFeatures(fc: FeatureCollection): Promise<string[]>;
|
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
+
import type { GeoJSONExportAdapter } from "../utils/geojson";
|
|
3
|
+
export type GeoKitStatusState = "uninitialized" | "initializing" | "ready" | "loading" | "error";
|
|
4
|
+
export interface GeoKitDiagnosticSummary {
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
recoverable: boolean;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Details for the 'leaflet-geokit:status' event and the element `status` getter.
|
|
12
|
+
*/
|
|
13
|
+
export interface StatusEventDetail {
|
|
14
|
+
state: GeoKitStatusState;
|
|
15
|
+
ready: boolean;
|
|
16
|
+
busy: boolean;
|
|
17
|
+
featureCount: number;
|
|
18
|
+
lastEvent?: string;
|
|
19
|
+
lastError?: GeoKitDiagnosticSummary;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Details for the 'leaflet-geokit:diagnostic' event.
|
|
24
|
+
*/
|
|
25
|
+
export interface DiagnosticEventDetail extends GeoKitDiagnosticSummary {
|
|
26
|
+
severity: "info" | "warn" | "error";
|
|
27
|
+
state: GeoKitStatusState;
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
}
|
|
2
30
|
/**
|
|
3
31
|
* Details for the 'leaflet-draw:ready' event.
|
|
4
32
|
* bounds: optional southwest/northeast LatLng pairs.
|
|
@@ -34,8 +62,7 @@ export interface DeletedEventDetail {
|
|
|
34
62
|
/**
|
|
35
63
|
* Details for error events emitted as 'leaflet-draw:error'.
|
|
36
64
|
*/
|
|
37
|
-
export interface ErrorEventDetail {
|
|
38
|
-
message: string;
|
|
65
|
+
export interface ErrorEventDetail extends GeoKitDiagnosticSummary {
|
|
39
66
|
cause?: unknown;
|
|
40
67
|
}
|
|
41
68
|
/**
|
|
@@ -52,6 +79,7 @@ export interface IngestEventDetail {
|
|
|
52
79
|
export interface ExportEventDetail {
|
|
53
80
|
geoJSON: FeatureCollection;
|
|
54
81
|
featureCount: number;
|
|
82
|
+
adapter: GeoJSONExportAdapter;
|
|
55
83
|
}
|
|
56
84
|
/**
|
|
57
85
|
* Event name constants for convenience (non-enforced).
|
|
@@ -64,8 +92,8 @@ export declare const DrawEvent: {
|
|
|
64
92
|
readonly Error: "leaflet-draw:error";
|
|
65
93
|
readonly Ingest: "leaflet-draw:ingest";
|
|
66
94
|
readonly Export: "leaflet-draw:export";
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
readonly
|
|
70
|
-
readonly
|
|
95
|
+
};
|
|
96
|
+
export declare const GeoKitEvent: {
|
|
97
|
+
readonly Status: "leaflet-geokit:status";
|
|
98
|
+
readonly Diagnostic: "leaflet-geokit:diagnostic";
|
|
71
99
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection, Geometry } from "geojson";
|
|
2
2
|
import type { LogLevel } from "../utils/logger";
|
|
3
|
+
import type { StatusEventDetail } from "../types/events";
|
|
4
|
+
import type { GeoJSONExportAdapter, GeoJSONExportOptions, GeoJSONImportBehavior, GeoJSONImportOptions } from "../utils/geojson";
|
|
3
5
|
import type * as Leaflet from "leaflet";
|
|
4
6
|
/**
|
|
5
7
|
* Basic map configuration derived from element attributes.
|
|
@@ -46,7 +48,7 @@ export interface MarkerIconConfig {
|
|
|
46
48
|
/** Popup anchor relative to iconAnchor: [x, y]. Defaults to [1, -34]. */
|
|
47
49
|
popupAnchor?: MarkerIconPoint;
|
|
48
50
|
}
|
|
49
|
-
export type ToolButtonName = "polygon" | "polyline" | "rectangle" | "circle" | "marker" | "layerCake" | "move" | "select" | "edit" | "delete" | "ruler" | "measurementSettings" | "layerStyle";
|
|
51
|
+
export type ToolButtonName = "polygon" | "polyline" | "rectangle" | "circle" | "marker" | "layerCake" | "move" | "select" | "edit" | "delete" | "ruler" | "measurementSettings" | "layerStyle" | "save";
|
|
50
52
|
export interface ToolButtonRenderContext {
|
|
51
53
|
tool: ToolButtonName;
|
|
52
54
|
groupId?: string;
|
|
@@ -105,6 +107,11 @@ export interface ToolToolbarGroupConfig {
|
|
|
105
107
|
className?: string;
|
|
106
108
|
/** Pixel offset from the chosen map corner. Defaults to [10, 10]. */
|
|
107
109
|
offset?: MarkerIconPoint;
|
|
110
|
+
/**
|
|
111
|
+
* Hide the built-in Leaflet.draw/ruler toolbars while this custom group is present.
|
|
112
|
+
* Defaults to true so custom buttons are the only visible map tool chrome.
|
|
113
|
+
*/
|
|
114
|
+
hideDefaultToolbar?: boolean;
|
|
108
115
|
}
|
|
109
116
|
export interface ToolTriggerOptions {
|
|
110
117
|
/** Source label included in public trigger events. */
|
|
@@ -118,7 +125,7 @@ export interface ToolTriggerEventDetail extends ToolTriggerOptions {
|
|
|
118
125
|
timestamp: number;
|
|
119
126
|
error?: string;
|
|
120
127
|
}
|
|
121
|
-
export type IntegratedToolEventName = "tool:polygon:created" | "tool:polyline:created" | "tool:rectangle:created" | "tool:circle:created" | "tool:marker:created" | "tool:layer-cake:session-started" | "tool:layer-cake:saved" | "tool:move:pending" | "tool:move:confirmed" | "tool:move:cancelled" | "tool:edit:applied" | "tool:delete:applied" | "tool:ruler:units-changed";
|
|
128
|
+
export type IntegratedToolEventName = "tool:polygon:created" | "tool:polyline:created" | "tool:rectangle:created" | "tool:circle:created" | "tool:marker:created" | "tool:layer-cake:session-started" | "tool:layer-cake:saved" | "tool:move:pending" | "tool:move:confirmed" | "tool:move:cancelled" | "tool:edit:applied" | "tool:delete:applied" | "tool:ruler:units-changed" | "tool:save";
|
|
122
129
|
export type IntegratedToolHooks = Partial<Record<IntegratedToolEventName, (detail: unknown) => void>>;
|
|
123
130
|
export interface IntegratedToolEventEmitter {
|
|
124
131
|
emit?: (eventName: IntegratedToolEventName, detail: unknown) => void;
|
|
@@ -240,7 +247,10 @@ export interface LeafletDrawMapElementAPI {
|
|
|
240
247
|
tileStyle?: string;
|
|
241
248
|
/** API key for authenticated providers */
|
|
242
249
|
apiKey?: string;
|
|
250
|
+
/** Durable readiness/loading/error snapshot mirrored by `leaflet-geokit:status`. */
|
|
251
|
+
readonly status: StatusEventDetail;
|
|
243
252
|
getGeoJSON(): Promise<FeatureCollection>;
|
|
253
|
+
importGeoJSON(fc: FeatureCollection, options?: GeoJSONImportOptions): Promise<string[]>;
|
|
244
254
|
loadGeoJSON(fc: FeatureCollection): Promise<void>;
|
|
245
255
|
clearLayers(): Promise<void>;
|
|
246
256
|
addFeatures(fc: FeatureCollection): Promise<string[]>;
|
|
@@ -253,13 +263,13 @@ export interface LeafletDrawMapElementAPI {
|
|
|
253
263
|
*/
|
|
254
264
|
fitBounds(bounds: [[number, number], [number, number]], padding?: number): Promise<void>;
|
|
255
265
|
setView(lat: number, lng: number, zoom?: number): Promise<void>;
|
|
256
|
-
loadGeoJSONFromUrl(url: string): Promise<void>;
|
|
257
|
-
loadGeoJSONFromText(text: string): Promise<void>;
|
|
266
|
+
loadGeoJSONFromUrl(url: string, options?: GeoJSONImportOptions): Promise<void>;
|
|
267
|
+
loadGeoJSONFromText(text: string, options?: GeoJSONImportOptions): Promise<void>;
|
|
258
268
|
/**
|
|
259
269
|
* Emits 'leaflet-draw:export' with the current FeatureCollection.
|
|
260
270
|
* Returns the exported FeatureCollection for convenience.
|
|
261
271
|
*/
|
|
262
|
-
exportGeoJSON(): Promise<FeatureCollection>;
|
|
272
|
+
exportGeoJSON(options?: GeoJSONExportOptions): Promise<FeatureCollection>;
|
|
263
273
|
/**
|
|
264
274
|
* Merge all visible polygon layers into a single polygon.
|
|
265
275
|
* This removes the original polygon features and adds a new merged feature.
|
|
@@ -288,3 +298,4 @@ export interface LeafletDrawMapElementAPI {
|
|
|
288
298
|
deactivateTool(options?: ToolTriggerOptions): Promise<boolean>;
|
|
289
299
|
}
|
|
290
300
|
export type { Feature, FeatureCollection, Geometry };
|
|
301
|
+
export type { GeoJSONExportAdapter, GeoJSONExportOptions, GeoJSONImportBehavior, GeoJSONImportOptions, };
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection, Geometry, Position, Polygon, MultiPolygon, GeoJsonProperties } from "geojson";
|
|
2
|
+
export type GeoJSONImportBehavior = "replace" | "add";
|
|
3
|
+
export interface GeoJSONImportOptions {
|
|
4
|
+
behavior?: GeoJSONImportBehavior;
|
|
5
|
+
fitToData?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type GeoJSONExportAdapter = "editing" | "source";
|
|
8
|
+
export interface GeoJSONExportOptions {
|
|
9
|
+
adapter?: GeoJSONExportAdapter;
|
|
10
|
+
}
|
|
2
11
|
export type BBox = [
|
|
3
12
|
minLng: number,
|
|
4
13
|
minLat: number,
|
|
@@ -37,6 +46,7 @@ export declare function bboxToBoundsPair(b: BBox): BoundsPair;
|
|
|
37
46
|
* Other geometry types are returned unchanged.
|
|
38
47
|
*/
|
|
39
48
|
export declare function expandMultiGeometries(fc: FeatureCollection): FeatureCollection;
|
|
49
|
+
export declare function adaptFeatureCollectionForExport(fc: FeatureCollection, options?: GeoJSONExportOptions): FeatureCollection;
|
|
40
50
|
/**
|
|
41
51
|
* Check if a geometry is a Polygon
|
|
42
52
|
*/
|
package/package.json
CHANGED