@record-evolution/widget-mapbox 1.5.2 → 1.5.3
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/dist/src/widget-mapbox.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/widget-mapbox.js +37 -16
- package/dist/widget-mapbox.js.map +1 -1
- package/package.json +1 -1
- package/src/widget-mapbox.ts +37 -15
package/package.json
CHANGED
package/src/widget-mapbox.ts
CHANGED
|
@@ -43,7 +43,7 @@ export class WidgetMapbox extends LitElement {
|
|
|
43
43
|
|
|
44
44
|
disconnectedCallback() {
|
|
45
45
|
super.disconnectedCallback()
|
|
46
|
-
if(this.resizeObserver) {
|
|
46
|
+
if (this.resizeObserver) {
|
|
47
47
|
this.resizeObserver.disconnect()
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -67,16 +67,33 @@ export class WidgetMapbox extends LitElement {
|
|
|
67
67
|
|
|
68
68
|
this.customDebounce = setTimeout(() => {
|
|
69
69
|
this.map?.resize()
|
|
70
|
-
this.fitBounds()
|
|
70
|
+
this.fitBounds()
|
|
71
71
|
}, 300)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
isArrayOfTwoNumbers(v: any) {
|
|
75
|
+
return (
|
|
76
|
+
Array.isArray(v) && // Check if it's an array
|
|
77
|
+
v.length <= 3 && // Check if the array has exactly two elements
|
|
78
|
+
typeof v[0] === 'number' && // Check if the first element is a number
|
|
79
|
+
typeof v[1] === 'number' // Check if the second element is a number
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
74
83
|
fitBounds() {
|
|
75
84
|
const bounds = new mapboxgl.LngLatBounds()
|
|
76
85
|
this.dataSources.forEach((col: GeoJSON.FeatureCollection) => {
|
|
77
86
|
col.features.forEach((f) => {
|
|
78
87
|
// @ts-ignore
|
|
79
|
-
if (
|
|
88
|
+
if (this.isArrayOfTwoNumbers(f.geometry?.coordinates)) {
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
bounds.extend(f.geometry.coordinates)
|
|
91
|
+
} else {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
for (const lnglat of f.geometry.coordinates) {
|
|
94
|
+
if (this.isArrayOfTwoNumbers(lnglat)) bounds.extend(lnglat)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
80
97
|
})
|
|
81
98
|
})
|
|
82
99
|
if (bounds.isEmpty()) {
|
|
@@ -129,7 +146,7 @@ export class WidgetMapbox extends LitElement {
|
|
|
129
146
|
// Filter for latest Values
|
|
130
147
|
this.dataSets.forEach((ds) => {
|
|
131
148
|
if (ds?.latestValues && ds?.latestValues > 0) {
|
|
132
|
-
ds.data = ds?.data?.slice(
|
|
149
|
+
ds.data = ds?.data?.slice(-ds.latestValues || -1) ?? []
|
|
133
150
|
}
|
|
134
151
|
})
|
|
135
152
|
|
|
@@ -586,6 +603,17 @@ export class WidgetMapbox extends LitElement {
|
|
|
586
603
|
a.mapboxgl-ctrl-logo {
|
|
587
604
|
display: none;
|
|
588
605
|
}
|
|
606
|
+
|
|
607
|
+
.no-data {
|
|
608
|
+
font-size: 20px;
|
|
609
|
+
color: var(--re-text-color, #000);
|
|
610
|
+
display: flex;
|
|
611
|
+
height: 100%;
|
|
612
|
+
width: 100%;
|
|
613
|
+
text-align: center;
|
|
614
|
+
align-items: center;
|
|
615
|
+
justify-content: center;
|
|
616
|
+
}
|
|
589
617
|
`
|
|
590
618
|
|
|
591
619
|
render() {
|
|
@@ -595,17 +623,10 @@ export class WidgetMapbox extends LitElement {
|
|
|
595
623
|
rel="stylesheet"
|
|
596
624
|
/>
|
|
597
625
|
<div class="wrapper">
|
|
598
|
-
<header
|
|
599
|
-
class="paging"
|
|
600
|
-
?active=${this.inputData?.title || this.inputData?.subTitle}
|
|
601
|
-
>
|
|
626
|
+
<header class="paging" ?active=${this.inputData?.title || this.inputData?.subTitle}>
|
|
602
627
|
<div class="title">
|
|
603
|
-
<h3 class="paging" ?active=${this.inputData?.title}>
|
|
604
|
-
|
|
605
|
-
</h3>
|
|
606
|
-
<p class="paging" ?active=${this.inputData?.subTitle}>
|
|
607
|
-
${this.inputData?.subTitle}
|
|
608
|
-
</p>
|
|
628
|
+
<h3 class="paging" ?active=${this.inputData?.title}>${this.inputData?.title}</h3>
|
|
629
|
+
<p class="paging" ?active=${this.inputData?.subTitle}>${this.inputData?.subTitle}</p>
|
|
609
630
|
</div>
|
|
610
631
|
<div class="legend paging" ?active=${this?.inputData?.showLegend}>
|
|
611
632
|
${repeat(
|
|
@@ -624,7 +645,8 @@ export class WidgetMapbox extends LitElement {
|
|
|
624
645
|
)}
|
|
625
646
|
</div>
|
|
626
647
|
</header>
|
|
627
|
-
<div
|
|
648
|
+
<div class="paging no-data" ?active=${!this.dataSets.length}>No Data</div>
|
|
649
|
+
<div id="map" class="paging" ?active=${this.dataSets.length}></div>
|
|
628
650
|
</div>
|
|
629
651
|
`
|
|
630
652
|
}
|