Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Minor edge case fix for or-map-marker

Rich Turnerf5ae1d61671c
diff --git a/ui/component/or-map/src/mapwidget.ts b/ui/component/or-map/src/mapwidget.ts
index 3d07d913a..9df1c141e 100644
--- a/ui/component/or-map/src/mapwidget.ts
+++ b/ui/component/or-map/src/mapwidget.ts
@@ -404,7 +404,7 @@ export class MapWidget {
}
public addMarker(marker: OrMapMarker) {
- if (marker.lat && marker.lng) {
+ if (marker.hasPosition()) {
this._updateMarkerElement(marker, true);
}
}
@@ -423,13 +423,12 @@ export class MapWidget {
case "lat":
case "lng":
case "radius":
- if (marker.lat && marker.lng) {
+ if (marker.hasPosition()) {
if (marker._actualMarkerElement) {
this._updateMarkerPosition(marker);
} else {
this._updateMarkerElement(marker, true);
}
-
} else if (marker._actualMarkerElement) {
this._updateMarkerElement(marker, false);
}
diff --git a/ui/component/or-map/src/markers/or-map-marker.ts b/ui/component/or-map/src/markers/or-map-marker.ts
index 56b37ee75..847e43de0 100644
--- a/ui/component/or-map/src/markers/or-map-marker.ts
+++ b/ui/component/or-map/src/markers/or-map-marker.ts
@@ -325,4 +325,11 @@ export class OrMapMarker extends LitElement {
div.innerHTML = OrMapMarker._defaultTemplate(this.icon, {displayValue: this.displayValue, direction: this.direction});
return div;
}
+
+ public hasPosition(): boolean {
+ return typeof this.lat === "number"
+ && typeof this.lng === "number"
+ && this.lat >= -90 && this.lat < 90
+ && this.lng >= -180 && this.lng < 180;
+ }
}