@record-evolution/widget-mapbox 1.4.13 → 1.4.15

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.13",
6
+ "version": "1.4.15",
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(() => {
@@ -86,7 +86,7 @@ export class WidgetMapbox extends LitElement {
86
86
  this.dataSets = []
87
87
  this.inputData.dataseries.forEach((ds) => {
88
88
  const color = this.colors.get(ds.label)
89
- const distincts = [...new Set(ds.data?.map((d: Point) => d.pivot))]
89
+ const distincts = [...new Set(ds.data?.map((d: Point) => d.pivot))].sort()
90
90
  const derivedColors = tinycolor(color)
91
91
  .monochromatic(distincts.length)
92
92
  .map((c: any) => c.toHexString())
@@ -353,6 +353,10 @@ export class WidgetMapbox extends LitElement {
353
353
  }
354
354
 
355
355
  syncDataLayers() {
356
+ if (!this.mapLoaded) {
357
+ console.log('Map not yet finished loading. Skipping syncDataLayers')
358
+ return
359
+ }
356
360
  // remove sources and all Layers that are not part of the inputData anymore
357
361
  const sources: any[] = this.map.getStyle().sources ?? []
358
362
  const mySources: [string, any][] = Object.entries(sources).filter(([l]) => l.startsWith('input:'))
@@ -475,6 +479,7 @@ export class WidgetMapbox extends LitElement {
475
479
  console.log('MAPBOX VERSION', mapboxgl.version)
476
480
 
477
481
  this.map.on('load', () => {
482
+ this.mapLoaded = true
478
483
  this.addBuildingLayer()
479
484
  this.syncDataLayers()
480
485
  })
@@ -556,7 +561,10 @@ export class WidgetMapbox extends LitElement {
556
561
  rel="stylesheet"
557
562
  />
558
563
  <div class="wrapper">
559
- <header>
564
+ <header
565
+ class="paging"
566
+ ?active=${this.inputData?.settings?.title || this.inputData?.settings?.subTitle}
567
+ >
560
568
  <div class="title">
561
569
  <h3 class="paging" ?active=${this.inputData?.settings?.title}>
562
570
  ${this.inputData?.settings?.title}