@record-evolution/widget-mapbox 1.4.19 → 1.4.21
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
package/src/widget-mapbox.ts
CHANGED
|
@@ -30,17 +30,24 @@ export class WidgetMapbox extends LitElement {
|
|
|
30
30
|
private mapLoaded: boolean = false
|
|
31
31
|
private resizeObserver: ResizeObserver
|
|
32
32
|
private mapStyle?: string
|
|
33
|
+
private customDebounce?: any
|
|
33
34
|
private imageList: string[] = []
|
|
34
35
|
constructor() {
|
|
35
36
|
super()
|
|
36
37
|
this.resizeObserver = new ResizeObserver(() => {
|
|
37
|
-
this.
|
|
38
|
-
this.fitBounds()
|
|
38
|
+
this.updateMap()
|
|
39
39
|
})
|
|
40
40
|
mapboxgl.accessToken =
|
|
41
41
|
'pk.eyJ1IjoibWFya29wZSIsImEiOiJjazc1OWlsNjkwN2pyM2VxajV1eGRnYzgwIn0.3lVksk1nej_0KnWjCkBDAA'
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
disconnectedCallback() {
|
|
45
|
+
super.disconnectedCallback()
|
|
46
|
+
if(this.resizeObserver) {
|
|
47
|
+
this.resizeObserver.disconnect()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
44
51
|
update(changedProperties: Map<string, any>) {
|
|
45
52
|
if (changedProperties.has('inputData')) {
|
|
46
53
|
this.transformInputData()
|
|
@@ -55,6 +62,15 @@ export class WidgetMapbox extends LitElement {
|
|
|
55
62
|
this.fitBounds()
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
updateMap() {
|
|
66
|
+
if (this.customDebounce) clearTimeout(this.customDebounce)
|
|
67
|
+
|
|
68
|
+
this.customDebounce = setTimeout(() => {
|
|
69
|
+
this.map?.resize()
|
|
70
|
+
this.fitBounds()
|
|
71
|
+
}, 300)
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
fitBounds() {
|
|
59
75
|
const bounds = new mapboxgl.LngLatBounds()
|
|
60
76
|
this.dataSources.forEach((col: GeoJSON.FeatureCollection) => {
|
|
@@ -112,7 +128,9 @@ export class WidgetMapbox extends LitElement {
|
|
|
112
128
|
|
|
113
129
|
// Filter for latest Values
|
|
114
130
|
this.dataSets.forEach((ds) => {
|
|
115
|
-
if (ds?.latestValues && ds?.latestValues > 0)
|
|
131
|
+
if (ds?.latestValues && ds?.latestValues > 0) {
|
|
132
|
+
ds.data = ds?.data?.slice(0, ds.latestValues ?? 1) ?? []
|
|
133
|
+
}
|
|
116
134
|
})
|
|
117
135
|
|
|
118
136
|
// console.log('mapbox datasets', this.dataSets)
|