@teipublisher/pb-components 2.15.3 → 2.17.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 +14 -0
- package/css/leaflet/Control.Geocoder.css +126 -0
- package/dist/demo/demos.json +2 -1
- package/dist/pb-components-bundle.js +7 -2
- package/dist/pb-elements.json +27 -10
- package/dist/pb-leaflet-map.js +6 -5
- package/i18n/common/en.json +3 -0
- package/lib/Control.Geocoder.min.js +2 -0
- package/lib/Control.Geocoder.min.js.map +1 -0
- package/package.json +2 -1
- package/pb-elements.json +27 -10
- package/src/pb-events.js +38 -0
- package/src/pb-leaflet-map.js +545 -463
- package/src/pb-view-annotate.js +27 -16
package/pb-elements.json
CHANGED
|
@@ -5436,7 +5436,7 @@
|
|
|
5436
5436
|
{
|
|
5437
5437
|
"name": "pb-leaflet-map",
|
|
5438
5438
|
"path": "./src/pb-leaflet-map.js",
|
|
5439
|
-
"description": "A wrapper component for [leaflet](https://leafletjs.com/) displaying a map.\
|
|
5439
|
+
"description": "A wrapper component for [leaflet](https://leafletjs.com/) displaying a map.\n\nThe map layers displayed can be configured via nested `pb-map-layer` (see docs) elements,\nicons via `pb-map-icon`.",
|
|
5440
5440
|
"attributes": [
|
|
5441
5441
|
{
|
|
5442
5442
|
"name": "latitude",
|
|
@@ -5475,7 +5475,7 @@
|
|
|
5475
5475
|
},
|
|
5476
5476
|
{
|
|
5477
5477
|
"name": "toggle",
|
|
5478
|
-
"description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\
|
|
5478
|
+
"description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\nIn this case the map also offers a close button to hide it again.",
|
|
5479
5479
|
"type": "boolean",
|
|
5480
5480
|
"default": "false"
|
|
5481
5481
|
},
|
|
@@ -5487,7 +5487,7 @@
|
|
|
5487
5487
|
},
|
|
5488
5488
|
{
|
|
5489
5489
|
"name": "cluster",
|
|
5490
|
-
"description": "If set, combine markers into clusters if they are located too close together\
|
|
5490
|
+
"description": "If set, combine markers into clusters if they are located too close together\nto display as single markers",
|
|
5491
5491
|
"type": "boolean",
|
|
5492
5492
|
"default": "false"
|
|
5493
5493
|
},
|
|
@@ -5499,9 +5499,15 @@
|
|
|
5499
5499
|
},
|
|
5500
5500
|
{
|
|
5501
5501
|
"name": "disable-clustering-at",
|
|
5502
|
-
"description": "Limits up to which zoom level markers are arranged into clusters.\
|
|
5502
|
+
"description": "Limits up to which zoom level markers are arranged into clusters.\nUsing a higher zoom level here will result in more markers to be shown.\n\nRequires `cluster` option to be enabled.",
|
|
5503
5503
|
"type": "number"
|
|
5504
5504
|
},
|
|
5505
|
+
{
|
|
5506
|
+
"name": "geo-coding",
|
|
5507
|
+
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
|
|
5508
|
+
"type": "boolean",
|
|
5509
|
+
"default": "false"
|
|
5510
|
+
},
|
|
5505
5511
|
{
|
|
5506
5512
|
"name": "subscribe",
|
|
5507
5513
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -5537,7 +5543,7 @@
|
|
|
5537
5543
|
"properties": [
|
|
5538
5544
|
{
|
|
5539
5545
|
"name": "map",
|
|
5540
|
-
"description": "The underlying leafletjs map. Can be used for custom scripts.\
|
|
5546
|
+
"description": "The underlying leafletjs map. Can be used for custom scripts.\n\nWill be null until the component is fully loaded. Listen to `pb-ready` on the component to\nbe sure it has initialized."
|
|
5541
5547
|
},
|
|
5542
5548
|
{
|
|
5543
5549
|
"name": "latitude",
|
|
@@ -5584,7 +5590,7 @@
|
|
|
5584
5590
|
{
|
|
5585
5591
|
"name": "toggle",
|
|
5586
5592
|
"attribute": "toggle",
|
|
5587
|
-
"description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\
|
|
5593
|
+
"description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\nIn this case the map also offers a close button to hide it again.",
|
|
5588
5594
|
"type": "boolean",
|
|
5589
5595
|
"default": "false"
|
|
5590
5596
|
},
|
|
@@ -5598,7 +5604,7 @@
|
|
|
5598
5604
|
{
|
|
5599
5605
|
"name": "cluster",
|
|
5600
5606
|
"attribute": "cluster",
|
|
5601
|
-
"description": "If set, combine markers into clusters if they are located too close together\
|
|
5607
|
+
"description": "If set, combine markers into clusters if they are located too close together\nto display as single markers",
|
|
5602
5608
|
"type": "boolean",
|
|
5603
5609
|
"default": "false"
|
|
5604
5610
|
},
|
|
@@ -5612,9 +5618,16 @@
|
|
|
5612
5618
|
{
|
|
5613
5619
|
"name": "disableClusteringAt",
|
|
5614
5620
|
"attribute": "disable-clustering-at",
|
|
5615
|
-
"description": "Limits up to which zoom level markers are arranged into clusters.\
|
|
5621
|
+
"description": "Limits up to which zoom level markers are arranged into clusters.\nUsing a higher zoom level here will result in more markers to be shown.\n\nRequires `cluster` option to be enabled.",
|
|
5616
5622
|
"type": "number"
|
|
5617
5623
|
},
|
|
5624
|
+
{
|
|
5625
|
+
"name": "geoCoding",
|
|
5626
|
+
"attribute": "geo-coding",
|
|
5627
|
+
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
|
|
5628
|
+
"type": "boolean",
|
|
5629
|
+
"default": "false"
|
|
5630
|
+
},
|
|
5618
5631
|
{
|
|
5619
5632
|
"name": "subscribe",
|
|
5620
5633
|
"attribute": "subscribe",
|
|
@@ -5660,7 +5673,7 @@
|
|
|
5660
5673
|
},
|
|
5661
5674
|
{
|
|
5662
5675
|
"name": "pb-update-map",
|
|
5663
|
-
"description": "When received, redraws the map to fit markers passed in with the event.\
|
|
5676
|
+
"description": "When received, redraws the map to fit markers passed in with the event.\nEvent details should include an array of locations, see `pb-geolocation` event below."
|
|
5664
5677
|
},
|
|
5665
5678
|
{
|
|
5666
5679
|
"name": "pb-update",
|
|
@@ -5668,7 +5681,11 @@
|
|
|
5668
5681
|
},
|
|
5669
5682
|
{
|
|
5670
5683
|
"name": "pb-geolocation",
|
|
5671
|
-
"description": "When received, focuses the map on the geocoordinates passed in with the event.\
|
|
5684
|
+
"description": "When received, focuses the map on the geocoordinates passed in with the event.\nThe event details should include an object:\n```\n{\ncoordinates: {\n latitude: Number,\n longitude: Number\n},\nlabel: string - the label to show on mouseover,\nzoom: Number - fixed zoom level to zoom to,\nfitBounds: Boolean - if true, recompute current zoom level to show all markers\n}\n```"
|
|
5685
|
+
},
|
|
5686
|
+
{
|
|
5687
|
+
"name": "pb-geocode",
|
|
5688
|
+
"description": "emitted if geocoding is enabled and the user searches or selects a location from the map"
|
|
5672
5689
|
}
|
|
5673
5690
|
],
|
|
5674
5691
|
"slots": [
|
package/src/pb-events.js
CHANGED
|
@@ -78,6 +78,44 @@ export class PbEvents {
|
|
|
78
78
|
});
|
|
79
79
|
document.dispatchEvent(ev);
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Wait for one or more TEI Publisher web components to become ready (by waiting for their `pb-ready` event).
|
|
84
|
+
*
|
|
85
|
+
* @param {HTMLElement|HTMLElement[]} targets element or array of elements to check for ready state
|
|
86
|
+
* @returns Promise which resolves when all components are ready
|
|
87
|
+
*/
|
|
88
|
+
static ifReady(targets) {
|
|
89
|
+
if (!Array.isArray(targets)) {
|
|
90
|
+
targets = [targets];
|
|
91
|
+
}
|
|
92
|
+
// const targets = Array.from(document.querySelectorAll(selector));
|
|
93
|
+
return new Promise((resolve) => {
|
|
94
|
+
const targetCount = targets.length;
|
|
95
|
+
if (targetCount === 0) {
|
|
96
|
+
// selector did not return any targets
|
|
97
|
+
resolve();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
let count = targetCount;
|
|
101
|
+
targets.forEach((target) => {
|
|
102
|
+
if (target._isReady) {
|
|
103
|
+
count -= 1;
|
|
104
|
+
if (count === 0) {
|
|
105
|
+
resolve();
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const handler = target.addEventListener('pb-ready', () => {
|
|
110
|
+
count -= 1;
|
|
111
|
+
if (count === 0) {
|
|
112
|
+
target.removeEventListener('pb-ready', handler);
|
|
113
|
+
resolve();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
81
119
|
}
|
|
82
120
|
|
|
83
121
|
if (!window.pbEvents) {
|