@teipublisher/pb-components 1.32.0 → 1.33.1

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.
@@ -9,9 +9,22 @@ import './pb-map-layer.js';
9
9
  *
10
10
  * @slot - may contain a series of `pb-map-layer` configurations
11
11
  * @fires pb-leaflet-marker-click - Fires event to be processed by the map upon click
12
- * @fires pb-update-map - When received, redraws the map to fit markers passed in with the event
13
- * @fires pb-update - When received, redraws the map to show markers for all pb-geolocation elements
14
- * @fires pb-geolocation - When received, focuses the map on the geocoordinates passed in with the event
12
+ * @fires pb-update-map - When received, redraws the map to fit markers passed in with the event.
13
+ * Event details should include an array of locations, see `pb-geolocation` event below.
14
+ * @fires pb-update - When received, redraws the map to show markers for all pb-geolocation elements found in the content of the pb-view
15
+ * @fires pb-geolocation - When received, focuses the map on the geocoordinates passed in with the event.
16
+ * The event details should include an object:
17
+ * ```
18
+ * {
19
+ * coordinates: {
20
+ * latitude: Number,
21
+ * longitude: Number
22
+ * },
23
+ * label: string - the label to show on mouseover,
24
+ * zoom: Number - fixed zoom level to zoom to,
25
+ * fitBounds: Boolean - if true, recompute current zoom level to show all markers
26
+ * }
27
+ * ```
15
28
  */
16
29
  export class PbLeafletMap extends pbMixin(LitElement) {
17
30
  static get properties() {
@@ -43,6 +56,16 @@ export class PbLeafletMap extends pbMixin(LitElement) {
43
56
  cluster: {
44
57
  type: Boolean
45
58
  },
59
+ /**
60
+ * Limits up to which zoom level markers are arranged into clusters.
61
+ * Using a higher zoom level here will result in more markers to be shown.
62
+ *
63
+ * Requires `cluster` option to be enabled.
64
+ */
65
+ disableClusteringAt: {
66
+ type: Number,
67
+ attribute: 'disable-clustering-at'
68
+ },
46
69
  /**
47
70
  * If enabled, the map will not automatically scroll to the coordinates received via `pb-geolocation`
48
71
  */
@@ -89,6 +112,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
89
112
  this.disabled = true;
90
113
  this.cluster = false;
91
114
  this.fitMarkers = false;
115
+ this.disableClusteringAt = null;
92
116
  }
93
117
 
94
118
  connectedCallback() {
@@ -183,7 +207,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
183
207
  if (this.toggle) {
184
208
  this.disabled = false;
185
209
  }
186
- this._locationChanged(this.latitude, this.longitude);
210
+ this._locationChanged(this.latitude, this.longitude, ev.detail.zoom);
187
211
  }
188
212
  });
189
213
  }
@@ -252,7 +276,11 @@ export class PbLeafletMap extends pbMixin(LitElement) {
252
276
  this._configureLayers();
253
277
 
254
278
  if (this.cluster) {
255
- this._markerLayer = L.markerClusterGroup();
279
+ const options = {};
280
+ if (this.disableClusteringAt) {
281
+ options.disableClusteringAtZoom = this.disableClusteringAt;
282
+ }
283
+ this._markerLayer = L.markerClusterGroup(options);
256
284
  } else {
257
285
  this._markerLayer = L.layerGroup();
258
286
  }
@@ -351,16 +379,24 @@ export class PbLeafletMap extends pbMixin(LitElement) {
351
379
  }
352
380
  }
353
381
 
354
- _locationChanged(lat, long) {
382
+ _locationChanged(lat, long, zoom) {
355
383
  if (this._map) {
356
384
  const coords = L.latLng([lat, long]);
357
385
  this._markerLayer.eachLayer((layer) => {
358
386
  if (layer.getLatLng().equals(coords)) {
359
- layer.openTooltip();
387
+ if (zoom && !this.noScroll) {
388
+ layer.openTooltip();
389
+ this._map.setView(coords, zoom);
390
+ } else if (this.cluster) {
391
+ this._markerLayer.zoomToShowLayer(layer, () =>
392
+ layer.openTooltip()
393
+ );
394
+ } else {
395
+ layer.openTooltip();
396
+ this._map.setView(coords, this.zoom);
397
+ }
360
398
  }
361
399
  });
362
- if (!this.noScroll)
363
- this._map.setView(coords, this.zoom);
364
400
  }
365
401
  }
366
402
 
@@ -159,10 +159,10 @@ export class PbSplitList extends pbMixin(LitElement) {
159
159
  }
160
160
 
161
161
  header {
162
- display: grid;
163
- grid-auto-flow: column;
164
- width: 100%;
162
+ display: flex;
163
+ flex-wrap: wrap;
165
164
  column-gap: 10px;
165
+ width: 100%;
166
166
  }
167
167
 
168
168
  #items {