@record-evolution/widget-mapbox 1.4.14 → 1.4.16

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "REWidget widget-mapbox",
4
4
  "license": "MIT",
5
5
  "author": "widget-mapbox",
6
- "version": "1.4.14",
6
+ "version": "1.4.16",
7
7
  "type": "module",
8
8
  "main": "dist/widget-mapbox.js",
9
9
  "types": "dist/src/widget-mapbox.d.ts",
@@ -26,10 +26,10 @@ export class WidgetMapbox extends LitElement {
26
26
  @state()
27
27
  colors: any = new Map()
28
28
 
29
- version: string = 'versionplaceholder'
30
-
31
- resizeObserver: ResizeObserver
32
- mapStyle?: string
29
+ public version: string = 'versionplaceholder'
30
+ private mapLoaded: boolean = false
31
+ private resizeObserver: ResizeObserver
32
+ private mapStyle?: string
33
33
  constructor() {
34
34
  super()
35
35
  this.resizeObserver = new ResizeObserver(() => {
@@ -62,9 +62,10 @@ export class WidgetMapbox extends LitElement {
62
62
  if (f.geometry.coordinates?.length) bounds.extend(f.geometry.coordinates)
63
63
  })
64
64
  })
65
- if (!bounds.isEmpty()) {
66
- this.map.fitBounds(bounds, { maxZoom: 14, padding: 16, duration: 100 })
65
+ if (bounds.isEmpty()) {
66
+ bounds.extend([8.6820917, 50.1106444])
67
67
  }
68
+ this.map.fitBounds(bounds, { maxZoom: 14, padding: 16, duration: 100 })
68
69
  }
69
70
 
70
71
  transformInputData() {
@@ -353,6 +354,10 @@ export class WidgetMapbox extends LitElement {
353
354
  }
354
355
 
355
356
  syncDataLayers() {
357
+ if (!this.mapLoaded) {
358
+ console.log('Map not yet finished loading. Skipping syncDataLayers')
359
+ return
360
+ }
356
361
  // remove sources and all Layers that are not part of the inputData anymore
357
362
  const sources: any[] = this.map.getStyle().sources ?? []
358
363
  const mySources: [string, any][] = Object.entries(sources).filter(([l]) => l.startsWith('input:'))
@@ -475,6 +480,7 @@ export class WidgetMapbox extends LitElement {
475
480
  console.log('MAPBOX VERSION', mapboxgl.version)
476
481
 
477
482
  this.map.on('load', () => {
483
+ this.mapLoaded = true
478
484
  this.addBuildingLayer()
479
485
  this.syncDataLayers()
480
486
  })
@@ -556,7 +562,10 @@ export class WidgetMapbox extends LitElement {
556
562
  rel="stylesheet"
557
563
  />
558
564
  <div class="wrapper">
559
- <header>
565
+ <header
566
+ class="paging"
567
+ ?active=${this.inputData?.settings?.title || this.inputData?.settings?.subTitle}
568
+ >
560
569
  <div class="title">
561
570
  <h3 class="paging" ?active=${this.inputData?.settings?.title}>
562
571
  ${this.inputData?.settings?.title}