@florasync/leaflet-geokit 0.6.0 → 0.8.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/README.md +169 -0
- package/dist/django/index.js +1811 -1470
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +1695 -1354
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +1075 -734
- 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-CC8_JrcA.js → index-CudTfo4O.js} +1088 -747
- package/dist/preact/index-CudTfo4O.js.map +1 -0
- package/dist/preact/index.js +40 -38
- package/dist/preact/index.js.map +1 -1
- package/dist/preact-bundled/index.js +1721 -1378
- package/dist/preact-bundled/index.js.map +1 -1
- package/dist/react/{index-CC8_JrcA.js → index-CudTfo4O.js} +1088 -747
- package/dist/react/index-CudTfo4O.js.map +1 -0
- package/dist/react/index.js +29 -27
- package/dist/react/index.js.map +1 -1
- package/dist/react-bundled/index.js +1720 -1377
- package/dist/react-bundled/index.js.map +1 -1
- package/dist/types/e2e/tool-events-harness.spec.d.ts +1 -0
- package/dist/types/e2e/tool-hooks.spec.d.ts +1 -0
- package/dist/types/src/components/LeafletDrawMapElement.d.ts +25 -1
- package/dist/types/src/lib/MapController.d.ts +17 -1
- package/dist/types/src/lib/TileProviderFactory.d.ts +45 -0
- package/dist/types/src/preact/core.d.ts +5 -0
- package/dist/types/src/react/core.d.ts +5 -0
- package/dist/types/src/types/public.d.ts +68 -0
- package/dist/types/tests/component-branch-coverage.spec.d.ts +1 -0
- package/dist/types/tests/component-tile-provider.spec.d.ts +1 -0
- package/dist/types/tests/tile-provider-factory.spec.d.ts +1 -0
- package/package.json +1 -1
- package/dist/preact/index-CC8_JrcA.js.map +0 -1
- package/dist/react/index-CC8_JrcA.js.map +0 -1
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Documentation quick-links
|
|
|
26
26
|
|
|
27
27
|
- What you get
|
|
28
28
|
- Install
|
|
29
|
+
- Tile Providers
|
|
29
30
|
- Build and compilation
|
|
30
31
|
- Runtime and architecture overview
|
|
31
32
|
- Public API (attributes, properties, methods, events)
|
|
@@ -118,6 +119,52 @@ Why choose external?
|
|
|
118
119
|
|
|
119
120
|
---
|
|
120
121
|
|
|
122
|
+
## Tile Providers
|
|
123
|
+
|
|
124
|
+
The `<leaflet-geokit>` web component supports multiple tile provider modes.
|
|
125
|
+
|
|
126
|
+
### OpenStreetMap (Default)
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<leaflet-geokit tile-provider="osm"></leaflet-geokit>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### HERE Maps
|
|
133
|
+
|
|
134
|
+
Requires a HERE API key ([get one here](https://developer.here.com/)):
|
|
135
|
+
|
|
136
|
+
```html
|
|
137
|
+
<leaflet-geokit
|
|
138
|
+
tile-provider="here"
|
|
139
|
+
tile-style="lite.day"
|
|
140
|
+
api-key="YOUR_HERE_API_KEY"
|
|
141
|
+
></leaflet-geokit>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
`api-key` is the canonical attribute. `here-api-key` is also accepted as a legacy alias.
|
|
145
|
+
|
|
146
|
+
**Available HERE Styles**:
|
|
147
|
+
|
|
148
|
+
- `lite.day` - Lightweight basemap (default)
|
|
149
|
+
- `normal.day` - Standard street map
|
|
150
|
+
- `satellite.day` - Satellite imagery
|
|
151
|
+
|
|
152
|
+
### Custom Tile Server (Backward Compatible)
|
|
153
|
+
|
|
154
|
+
You can still use custom tile URLs:
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<leaflet-geokit
|
|
158
|
+
tile-url="https://example.com/tiles/{z}/{x}/{y}.png"
|
|
159
|
+
></leaflet-geokit>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Security Note
|
|
163
|
+
|
|
164
|
+
⚠️ For production use, **do not** expose API keys client-side. Use a server-side proxy to request tiles.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
121
168
|
## Build and compilation
|
|
122
169
|
|
|
123
170
|
Tooling
|
|
@@ -317,6 +364,12 @@ map.tileAttribution = "..."; // string | undefined
|
|
|
317
364
|
map.readOnly = true; // boolean
|
|
318
365
|
map.preferCanvas = false; // boolean
|
|
319
366
|
map.logLevel = "info"; // LogLevel
|
|
367
|
+
map.toolHooks = {
|
|
368
|
+
"tool:move:pending": (detail) => console.log("pending move", detail),
|
|
369
|
+
}; // optional integrated tool hooks
|
|
370
|
+
map.toolEventEmitter = {
|
|
371
|
+
emit: (eventName, detail) => console.log(eventName, detail),
|
|
372
|
+
}; // optional integrated tool event emitter
|
|
320
373
|
|
|
321
374
|
// Theming
|
|
322
375
|
map.themeCss = `
|
|
@@ -325,6 +378,122 @@ map.themeCss = `
|
|
|
325
378
|
`;
|
|
326
379
|
```
|
|
327
380
|
|
|
381
|
+
### Integrated Tool Hooks & Event Emitter
|
|
382
|
+
|
|
383
|
+
GeoKit exposes tool lifecycle events through two optional integration points:
|
|
384
|
+
|
|
385
|
+
- `map.toolHooks`: per-event callbacks keyed by event name
|
|
386
|
+
- `map.toolEventEmitter`: generic emitter object with either:
|
|
387
|
+
- `emit(eventName, detail)`
|
|
388
|
+
- or `dispatchEvent(new CustomEvent(eventName, { detail }))`
|
|
389
|
+
|
|
390
|
+
Both can be used together. If both are provided, both are called.
|
|
391
|
+
|
|
392
|
+
```javascript
|
|
393
|
+
const map = document.querySelector("leaflet-geokit");
|
|
394
|
+
|
|
395
|
+
map.toolHooks = {
|
|
396
|
+
"tool:move:pending": (detail) => {
|
|
397
|
+
console.log("Move pending", detail.layerId);
|
|
398
|
+
},
|
|
399
|
+
"tool:ruler:units-changed": (detail) => {
|
|
400
|
+
console.log("Units changed", detail.previous, "->", detail.current);
|
|
401
|
+
},
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
map.toolEventEmitter = {
|
|
405
|
+
emit: (eventName, detail) => {
|
|
406
|
+
analytics.track(eventName, detail);
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Important behavior notes:
|
|
412
|
+
|
|
413
|
+
- Hooks/emitter can be assigned before or after map initialization.
|
|
414
|
+
- Re-assigning `toolHooks`/`toolEventEmitter` at runtime updates active observers immediately.
|
|
415
|
+
- Assign `undefined` to clear either integration point.
|
|
416
|
+
|
|
417
|
+
#### Supported integrated tool event names
|
|
418
|
+
|
|
419
|
+
- `tool:polygon:created`
|
|
420
|
+
- `tool:polyline:created`
|
|
421
|
+
- `tool:rectangle:created`
|
|
422
|
+
- `tool:circle:created`
|
|
423
|
+
- `tool:marker:created`
|
|
424
|
+
- `tool:layer-cake:session-started`
|
|
425
|
+
- `tool:layer-cake:saved`
|
|
426
|
+
- `tool:move:pending`
|
|
427
|
+
- `tool:move:confirmed`
|
|
428
|
+
- `tool:move:cancelled`
|
|
429
|
+
- `tool:edit:applied`
|
|
430
|
+
- `tool:delete:applied`
|
|
431
|
+
- `tool:ruler:units-changed`
|
|
432
|
+
|
|
433
|
+
#### Event detail payloads
|
|
434
|
+
|
|
435
|
+
`tool:*:created` (polygon/polyline/rectangle/circle/marker):
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
{
|
|
439
|
+
id: string;
|
|
440
|
+
geoJSON: GeoJSON.Feature;
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
`tool:layer-cake:session-started`:
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
{
|
|
448
|
+
center: { lat: number; lng: number; ... };
|
|
449
|
+
radius: number;
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
`tool:layer-cake:saved`:
|
|
454
|
+
|
|
455
|
+
```ts
|
|
456
|
+
{
|
|
457
|
+
featureCollection: GeoJSON.FeatureCollection;
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
`tool:move:pending` / `tool:move:confirmed`:
|
|
462
|
+
|
|
463
|
+
```ts
|
|
464
|
+
{
|
|
465
|
+
layerId?: string;
|
|
466
|
+
originalGeoJSON?: GeoJSON.Feature;
|
|
467
|
+
newGeoJSON?: GeoJSON.Feature;
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
`tool:move:cancelled`:
|
|
472
|
+
|
|
473
|
+
```ts
|
|
474
|
+
{
|
|
475
|
+
layerId?: string;
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
`tool:edit:applied` / `tool:delete:applied`:
|
|
480
|
+
|
|
481
|
+
```ts
|
|
482
|
+
{
|
|
483
|
+
ids: string[];
|
|
484
|
+
geoJSON: GeoJSON.FeatureCollection;
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
`tool:ruler:units-changed`:
|
|
489
|
+
|
|
490
|
+
```ts
|
|
491
|
+
{
|
|
492
|
+
previous: "metric" | "imperial";
|
|
493
|
+
current: "metric" | "imperial";
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
328
497
|
### Methods
|
|
329
498
|
|
|
330
499
|
All methods return Promises and should be awaited. Invoke on the element instance:
|