100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Marker click event
robindekkerscd77507d6de1
diff --git a/ui/component/or-map/@types/mapbox.js.d.ts b/ui/component/or-map/@types/mapbox.js.d.tsindex 43d82faef..ae43c0188 100644--- a/ui/component/or-map/@types/mapbox.js.d.ts+++ b/ui/component/or-map/@types/mapbox.js.d.ts@@ -72,6 +72,7 @@ declare module "mapbox.js" {export class Marker extends Layer {setLatLng(latLng: LatLngLike): this;+ on(event: any, func: any): this;}class Layer {diff --git a/ui/component/or-map/markers/or-map-marker-asset.ts b/ui/component/or-map/markers/or-map-marker-asset.tsindex c86e4d49d..d53d66328 100644--- a/ui/component/or-map/markers/or-map-marker-asset.ts+++ b/ui/component/or-map/markers/or-map-marker-asset.ts@@ -46,7 +46,6 @@ export class OrMapMarkerAsset extends OrMapMarker {this.visible = false;return;}-this._createAssetMarker();// Model d.ts is clearly not perfect need to sort out Jackson annotationsthis.lat = (<any>location.coordinates)[1] || 0;@@ -75,8 +74,11 @@ export class OrMapMarkerAsset extends OrMapMarker {}private _createAssetMarker() {- this._ele = document.createElement("div");- this._ele.className = "marker";+ // Create basic element of _ele is undefined+ if(typeof this._ele === 'undefined') {+ this._ele = document.createElement("div");+ this._ele.className = "marker";+ }}}diff --git a/ui/component/or-map/markers/or-map-marker.ts b/ui/component/or-map/markers/or-map-marker.tsindex 44f9be029..eec7825b0 100644--- a/ui/component/or-map/markers/or-map-marker.ts+++ b/ui/component/or-map/markers/or-map-marker.ts@@ -94,6 +94,10 @@ export class OrMapMarker extends PolymerElement {}}+ //TODO make this optional?+ _onClick(e) {+ }+_createMarkerElement(): HTMLElement {let children = this._slot.assignedNodes({flatten:true});let len = children.length;diff --git a/ui/component/or-map/src/mapwidget.ts b/ui/component/or-map/src/mapwidget.tsindex 165b5378d..95872ac20 100644--- a/ui/component/or-map/src/mapwidget.ts+++ b/ui/component/or-map/src/mapwidget.ts@@ -112,7 +112,15 @@ export class MapWidget {case Type.RASTER:let icon = L.divIcon({className: 'map-marker', html: marker._ele.outerHTML});let m: Marker = L.marker([marker.lat, marker.lng], {icon: icon});+++m.addTo(this._mapJs!);++ if(marker._onClick) {+ m.on('click', marker._onClick);+ }+this._markersJs!.set(marker, m);break;case Type.VECTOR: