@florasync/leaflet-geokit 0.7.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 +122 -0
- package/dist/django/index.js +390 -294
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +786 -690
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +284 -188
- package/dist/leaflet-geokit.external.es.js.map +1 -1
- package/dist/leaflet-geokit.umd.js +7 -7
- package/dist/leaflet-geokit.umd.js.map +1 -1
- package/dist/preact/{index-DagV_wwR.js → index-CudTfo4O.js} +283 -187
- 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 +278 -180
- package/dist/preact-bundled/index.js.map +1 -1
- package/dist/react/{index-DagV_wwR.js → index-CudTfo4O.js} +283 -187
- 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 +278 -180
- 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 +7 -1
- package/dist/types/src/lib/MapController.d.ts +10 -1
- 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 +10 -0
- package/package.json +1 -1
- package/dist/preact/index-DagV_wwR.js.map +0 -1
- package/dist/react/index-DagV_wwR.js.map +0 -1
package/README.md
CHANGED
|
@@ -364,6 +364,12 @@ map.tileAttribution = "..."; // string | undefined
|
|
|
364
364
|
map.readOnly = true; // boolean
|
|
365
365
|
map.preferCanvas = false; // boolean
|
|
366
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
|
|
367
373
|
|
|
368
374
|
// Theming
|
|
369
375
|
map.themeCss = `
|
|
@@ -372,6 +378,122 @@ map.themeCss = `
|
|
|
372
378
|
`;
|
|
373
379
|
```
|
|
374
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
|
+
|
|
375
497
|
### Methods
|
|
376
498
|
|
|
377
499
|
All methods return Promises and should be awaited. Invoke on the element instance:
|