Skip to content

armgit / core

Public Imported from GitHub
0

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

UI updates: or-map

Rich Turnerd65b8c77ea7f
diff --git a/ui/component/or-map/markers/or-map-marker-asset.ts b/ui/component/or-map/markers/or-map-marker-asset.ts
index 16177b9b5..c86e4d49d 100644
--- a/ui/component/or-map/markers/or-map-marker-asset.ts
+++ b/ui/component/or-map/markers/or-map-marker-asset.ts
@@ -16,27 +16,31 @@ export class OrMapMarkerAsset extends OrMapMarker {
@property({type: String, observer: "_assetChanged"})
asset?: string;
+ @property({type: Object})
+ _ele!: HTMLElement;
+
constructor() {
super();
}
_createMarkerElement(): HTMLElement {
- return document.createElement("div");
+ let className = ("or-map-marker " + this.className).trim();
+ let ele = document.createElement("div");
+ ele.className = className;
+ return ele;
}
refreshMarker() {
this.getAsset().then((asset) => {
- const attrs: Array<AssetAttribute> = <Array<AssetAttribute>>asset.attributes;
- const attr: AssetAttribute | undefined = attrs.find(attr => {
- return attr.name === "location"
- });
+ const attrs = <any>asset.attributes;
+ const attr: AssetAttribute | undefined = attrs.location;
if (!attr) {
this.visible = false;
return;
}
- const location: GeoJSONPoint | null = attr.valueAsObject as GeoJSONPoint;
+ const location: GeoJSONPoint | null = attr.value as GeoJSONPoint;
if (!location) {
this.visible = false;
@@ -44,8 +48,9 @@ export class OrMapMarkerAsset extends OrMapMarker {
}
this._createAssetMarker();
- this.lat = location.y || 0;
- this.lng = location.x || 0;
+ // Model d.ts is clearly not perfect need to sort out Jackson annotations
+ this.lat = (<any>location.coordinates)[1] || 0;
+ this.lng = (<any>location.coordinates)[0] || 0;
this.visible = true;
}).catch(() => {
this.visible = false;
diff --git a/ui/component/or-map/markers/or-map-marker.ts b/ui/component/or-map/markers/or-map-marker.ts
index 4dc1a17c5..44f9be029 100644
--- a/ui/component/or-map/markers/or-map-marker.ts
+++ b/ui/component/or-map/markers/or-map-marker.ts
@@ -19,7 +19,7 @@ export class OrMapMarker extends PolymerElement {
@property({type: Boolean})
visible: boolean = true;
- @property({type: Object})
+ @property({type: Object, computed: "_createMarkerElement()"})
_ele!: HTMLElement;
@property({type: Object})
diff --git a/ui/component/or-map/src/mapwidget.ts b/ui/component/or-map/src/mapwidget.ts
index 025254605..165b5378d 100644
--- a/ui/component/or-map/src/mapwidget.ts
+++ b/ui/component/or-map/src/mapwidget.ts
@@ -116,10 +116,10 @@ export class MapWidget {
this._markersJs!.set(marker, m);
break;
case Type.VECTOR:
- console.log(marker,marker.latitude, marker.longitude, this._mapGl);
- new MarkerGL(marker.html)
- .setLngLat([marker.latitude, marker.longitude])
- .addTo(this._mapGl);
+ console.log(marker,marker.lat, marker.lng, this._mapGl);
+ new MarkerGL(marker._ele)
+ .setLngLat([marker.lat, marker.lng])
+ .addTo(this._mapGl!);
break;
}
}