@openremote/or-map 1.8.0-snapshot.20250725074716 → 1.8.0-snapshot.20250725120001

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.
@@ -1 +1,178 @@
1
- var __decorate=this&&this.__decorate||function(t,e,r,i){var s,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,i);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(o<3?s(a):o>3?s(e,r,a):s(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a},__awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))(function(s,o){function a(t){try{c(i.next(t))}catch(t){o(t)}}function n(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?s(t.value):((e=t.value)instanceof r?e:new r(function(t){t(e)})).then(a,n)}c((i=i.apply(t,e||[])).next())})};import{customElement as t,property as e}from"lit/decorators.js";import{OrMapMarker as r}from"./or-map-marker";import{AssetModelUtil as i}from"@openremote/model";import s,{subscribe as o,Util as a}from"@openremote/core";import{getMarkerIconAndColorFromAssetType as n}from"../util";export function getMarkerConfigForAssetType(t,e){if(t&&e&&t[e])return t[e]}export function getMarkerConfigAttributeName(t,e){let r=getMarkerConfigForAssetType(t,e);if(r)return r.attributeName}let OrMapMarkerAsset=class extends o(s)(r){constructor(){super(),this.assetTypeAsIcon=!0,this.visible=!1}set type(t){let e,r=getMarkerConfigForAssetType(this.config,t);if(r&&r.attributeName&&this.asset&&this.asset.attributes&&this.asset.attributes[r.attributeName]&&r.colours){let t=this.asset.attributes[r.attributeName].value;e={markerConfig:r.colours,currentValue:t}}let i=n(t,e);if(!i){this.visible=!1;return}this.assetTypeAsIcon&&(this.icon=i.icon),this.markerColor=Array.isArray(i.color)?i.color[0].colour:i.color||void 0,this.updateColor(this.markerContainer),this.visible=!0}shouldUpdate(t){if(t.has("assetId")&&(this.lat=void 0,this.lng=void 0,this.type=void 0,this.direction=void 0,this.displayValue=void 0,this.assetIds=this.assetId&&this.assetId.length>0?[this.assetId]:void 0,1===Object.keys(t).length))return!1;if(t.has("asset"))try{this.onAssetChanged(this.asset)}catch(t){console.error(t)}return super.shouldUpdate(t)}_onEvent(t){if("attribute"===t.eventType)return"location"===t.ref.name?void this._updateLocation(t.value):void(this.asset&&(this.asset=a.updateAsset(this.asset,t),this.requestUpdate()));if("asset"===t.eventType)switch(t.cause){case"READ":case"CREATE":case"UPDATE":this.onAssetChanged(t.asset);break;case"DELETE":this.onAssetChanged(void 0)}}onAssetChanged(t){return __awaiter(this,void 0,void 0,function*(){if(t){this.direction=void 0,this.displayValue=void 0;let e=t.attributes?t.attributes.location:void 0;this._updateLocation(e?e.value:null);let r=getMarkerConfigForAssetType(this.config,t.type),s=!r||!r.hideDirection,o=r&&!0===r.showLabel&&!!r.attributeName,n=!!(r&&!1!==r.showUnits);if(o&&t.attributes&&t.attributes[null==r?void 0:r.attributeName]){let e=t.attributes[r.attributeName],s=i.getAttributeAndValueDescriptors(t.type,e.name,e);this.displayValue=a.getAttributeValueAsString(e,s[0],t.type,n,"-")}if(s&&t.attributes&&t.attributes.direction){let e=t.attributes.direction.value;null!=e&&(this.direction=e.toString())}this.type=t.type}else this.lat=void 0,this.lng=void 0})}_updateLocation(t){this.lat=t&&t.coordinates?t.coordinates[1]:void 0,this.lng=t&&t.coordinates?t.coordinates[0]:void 0}getColor(){return this.markerColor&&!this.color?"#"+this.markerColor:super.getColor()}getActiveColor(){return this.markerColor&&!this.activeColor?"#"+this.markerColor:super.getActiveColor()}};__decorate([e({type:String,reflect:!0,attribute:!0})],OrMapMarkerAsset.prototype,"assetId",void 0),__decorate([e({type:Object,attribute:!0})],OrMapMarkerAsset.prototype,"asset",void 0),__decorate([e()],OrMapMarkerAsset.prototype,"config",void 0),OrMapMarkerAsset=__decorate([t("or-map-marker-asset")],OrMapMarkerAsset);export{OrMapMarkerAsset};
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ import { customElement, property } from "lit/decorators.js";
17
+ import { OrMapMarker } from "./or-map-marker";
18
+ import { AssetModelUtil } from "@openremote/model";
19
+ import manager, { subscribe, Util } from "@openremote/core";
20
+ import { getMarkerIconAndColorFromAssetType } from "../util";
21
+ export function getMarkerConfigForAssetType(config, assetType) {
22
+ if (!config || !assetType || !config[assetType]) {
23
+ return;
24
+ }
25
+ return config[assetType];
26
+ }
27
+ export function getMarkerConfigAttributeName(config, assetType) {
28
+ const assetTypeConfig = getMarkerConfigForAssetType(config, assetType);
29
+ if (!assetTypeConfig) {
30
+ return;
31
+ }
32
+ return assetTypeConfig.attributeName;
33
+ }
34
+ let OrMapMarkerAsset = class OrMapMarkerAsset extends subscribe(manager)(OrMapMarker) {
35
+ constructor() {
36
+ super();
37
+ this.assetTypeAsIcon = true;
38
+ this.visible = false;
39
+ }
40
+ set type(type) {
41
+ let overrideOpts;
42
+ const assetTypeConfig = getMarkerConfigForAssetType(this.config, type);
43
+ if (assetTypeConfig && assetTypeConfig.attributeName && this.asset && this.asset.attributes && this.asset.attributes[assetTypeConfig.attributeName] && assetTypeConfig.colours) {
44
+ const currentValue = this.asset.attributes[assetTypeConfig.attributeName].value;
45
+ overrideOpts = {
46
+ markerConfig: assetTypeConfig.colours,
47
+ currentValue: currentValue
48
+ };
49
+ }
50
+ const iconAndColour = getMarkerIconAndColorFromAssetType(type, overrideOpts);
51
+ if (!iconAndColour) {
52
+ this.visible = false;
53
+ return;
54
+ }
55
+ if (this.assetTypeAsIcon) {
56
+ this.icon = iconAndColour.icon;
57
+ }
58
+ this.markerColor = (Array.isArray(iconAndColour.color)) ? iconAndColour.color[0].colour : iconAndColour.color || undefined;
59
+ this.updateColor(this.markerContainer);
60
+ this.visible = true;
61
+ }
62
+ shouldUpdate(_changedProperties) {
63
+ if (_changedProperties.has("assetId")) {
64
+ this.lat = undefined;
65
+ this.lng = undefined;
66
+ this.type = undefined;
67
+ this.direction = undefined;
68
+ this.displayValue = undefined;
69
+ this.assetIds = this.assetId && this.assetId.length > 0 ? [this.assetId] : undefined;
70
+ if (Object.keys(_changedProperties).length === 1) {
71
+ return false;
72
+ }
73
+ }
74
+ if (_changedProperties.has("asset")) {
75
+ try {
76
+ this.onAssetChanged(this.asset);
77
+ }
78
+ catch (e) {
79
+ console.error(e);
80
+ }
81
+ }
82
+ return super.shouldUpdate(_changedProperties);
83
+ }
84
+ /**
85
+ * This will only get called when assetId is set; if asset is set then it is expected that attribute changes are
86
+ * handled outside this component and the asset should be replaced when attributes change that require the marker
87
+ * to re-render
88
+ */
89
+ _onEvent(event) {
90
+ if (event.eventType === "attribute") {
91
+ const attributeEvent = event;
92
+ if (attributeEvent.ref.name === "location" /* WellknownAttributes.LOCATION */) {
93
+ this._updateLocation(attributeEvent.value);
94
+ return;
95
+ }
96
+ if (this.asset) {
97
+ this.asset = Util.updateAsset(this.asset, event);
98
+ this.requestUpdate();
99
+ }
100
+ return;
101
+ }
102
+ if (event.eventType === "asset") {
103
+ const assetEvent = event;
104
+ switch (assetEvent.cause) {
105
+ case "READ" /* AssetEventCause.READ */:
106
+ case "CREATE" /* AssetEventCause.CREATE */:
107
+ case "UPDATE" /* AssetEventCause.UPDATE */:
108
+ this.onAssetChanged(assetEvent.asset);
109
+ break;
110
+ case "DELETE" /* AssetEventCause.DELETE */:
111
+ this.onAssetChanged(undefined);
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ onAssetChanged(asset) {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ if (asset) {
119
+ this.direction = undefined;
120
+ this.displayValue = undefined;
121
+ const locAttr = asset.attributes ? asset.attributes["location" /* WellknownAttributes.LOCATION */] : undefined;
122
+ this._updateLocation(locAttr ? locAttr.value : null);
123
+ const assetTypeConfig = getMarkerConfigForAssetType(this.config, asset.type);
124
+ const showDirection = !assetTypeConfig || !assetTypeConfig.hideDirection;
125
+ const showLabel = assetTypeConfig && assetTypeConfig.showLabel === true && !!assetTypeConfig.attributeName;
126
+ const showUnits = !!(assetTypeConfig && assetTypeConfig.showUnits !== false);
127
+ if (showLabel && asset.attributes && asset.attributes[assetTypeConfig === null || assetTypeConfig === void 0 ? void 0 : assetTypeConfig.attributeName]) {
128
+ const attr = asset.attributes[assetTypeConfig.attributeName];
129
+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(asset.type, attr.name, attr);
130
+ this.displayValue = Util.getAttributeValueAsString(attr, descriptors[0], asset.type, showUnits, "-");
131
+ }
132
+ if (showDirection) {
133
+ if (asset.attributes && asset.attributes["direction" /* WellknownAttributes.DIRECTION */]) {
134
+ const directionVal = asset.attributes["direction" /* WellknownAttributes.DIRECTION */].value;
135
+ if (directionVal !== undefined && directionVal !== null) {
136
+ this.direction = directionVal.toString();
137
+ }
138
+ }
139
+ }
140
+ this.type = asset.type;
141
+ }
142
+ else {
143
+ this.lat = undefined;
144
+ this.lng = undefined;
145
+ }
146
+ });
147
+ }
148
+ _updateLocation(location) {
149
+ this.lat = location && location.coordinates ? location.coordinates[1] : undefined;
150
+ this.lng = location && location.coordinates ? location.coordinates[0] : undefined;
151
+ }
152
+ getColor() {
153
+ if (this.markerColor && !this.color) {
154
+ return "#" + this.markerColor;
155
+ }
156
+ return super.getColor();
157
+ }
158
+ getActiveColor() {
159
+ if (this.markerColor && !this.activeColor) {
160
+ return "#" + this.markerColor;
161
+ }
162
+ return super.getActiveColor();
163
+ }
164
+ };
165
+ __decorate([
166
+ property({ type: String, reflect: true, attribute: true })
167
+ ], OrMapMarkerAsset.prototype, "assetId", void 0);
168
+ __decorate([
169
+ property({ type: Object, attribute: true })
170
+ ], OrMapMarkerAsset.prototype, "asset", void 0);
171
+ __decorate([
172
+ property()
173
+ ], OrMapMarkerAsset.prototype, "config", void 0);
174
+ OrMapMarkerAsset = __decorate([
175
+ customElement("or-map-marker-asset")
176
+ ], OrMapMarkerAsset);
177
+ export { OrMapMarkerAsset };
178
+ //# sourceMappingURL=or-map-marker-asset.js.map
@@ -1,80 +1,335 @@
1
- var OrMapMarker_1,__decorate=this&&this.__decorate||function(e,t,r,a){var i,o=arguments.length,s=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var n=e.length-1;n>=0;n--)(i=e[n])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s};import{css as e,html as t,LitElement as r,unsafeCSS as a}from"lit";import{customElement as i,property as o,query as s}from"lit/decorators.js";import{markerActiveColorVar as n,markerColorVar as c}from"../style";import{DefaultBoxShadow as l}from"@openremote/core";export class OrMapMarkerChangedEvent extends CustomEvent{constructor(e,t){super(OrMapMarkerChangedEvent.NAME,{detail:{marker:e,property:t},bubbles:!0,composed:!0})}}OrMapMarkerChangedEvent.NAME="or-map-marker-changed";export class OrMapMarkerClickedEvent extends CustomEvent{constructor(e){super(OrMapMarkerClickedEvent.NAME,{detail:{marker:e},bubbles:!0,composed:!0})}}OrMapMarkerClickedEvent.NAME="or-map-marker-clicked";let OrMapMarker=OrMapMarker_1=class extends r{constructor(){super(...arguments),this.visible=!0,this.interactive=!0,this.active=!1}static get styles(){return e`
2
- .label {
3
- background-color: white;
4
- width: auto;
5
- height: 20px;
6
- position: absolute;
7
- top: -14px;
8
- left: 50%;
9
- padding: 0 3px;
10
- transform: translate(-50%, -50%);
11
- text-align: center;
12
- border-radius: 3px;
13
- -webkit-box-shadow: ${a(l)};
14
- -moz-box-shadow: ${a(l)};
15
- box-shadow: ${a(l)};
16
- }
17
- .label > span {
18
- white-space: nowrap;
19
- }
20
-
21
- .direction-icon-wrapper {
22
- position: absolute;
23
- top: 11px;
24
- left: 16px;
25
- }
26
- .direction-circle {
27
- position: absolute;
28
- margin-top: -15px;
29
- margin-left: -15px;
30
- width: 30px;
31
- height: 30px;
32
- }
33
- .direction-circle circle {
34
- cx: 15px;
35
- cy: 15px;
36
- r: 12px;
37
- stroke: white;
38
- stroke-width: 3px;
39
- fill: transparent;
40
- }
41
- .direction-icon {
42
- position: absolute;
43
- top: -25px;
44
- left: -16px;
45
- transform: scale(0.75) rotate(-90deg);
46
- }
47
-
48
- .active .direction-icon-wrapper {
49
- top: 17px;
50
- left: 24px;
51
- }
52
- .active .direction-circle {
53
- margin-top: -20px;
54
- margin-left: -20px;
55
- width: 40px;
56
- height: 40px;
57
- }
58
- .active .direction-icon {
59
- top: -36px;
60
- left: -23px;
61
- }
62
- .active .direction-circle circle {
63
- cx: 20px;
64
- cy: 20px;
65
- r: 18px;
66
- stroke-width: 4px;
67
- }
68
- `}get markerContainer(){if(this._actualMarkerElement)return this._actualMarkerElement.firstElementChild}_onClick(e){this.dispatchEvent(new OrMapMarkerClickedEvent(this))}_createMarkerElement(){let e=document.createElement("div"),t=document.createElement("div");e.appendChild(t),this.addMarkerClassNames(e),this.addMarkerContainerClassNames(t);let r=this.createMarkerContent();return r||(e.classList.add("or-map-marker-default"),r=this.createDefaultMarkerContent()),t.appendChild(r),this.updateInteractive(e),this.updateVisibility(e),this.updateColor(t),this.updateActive(e),e}createMarkerContent(){let e=!1,t=document.createElement("div");if(this._slot&&this._slot.assignedNodes({flatten:!0}).forEach(r=>{r instanceof HTMLElement&&(t.appendChild(r.cloneNode(!0)),e=!0)}),e)return t}shouldUpdate(e){return(e.has("icon")||e.has("displayValue")||e.has("direction"))&&this.refreshMarkerContent(),(e.has("color")||e.has("activeColor"))&&this.updateColor(this.markerContainer),e.has("visible")&&this.updateVisibility(this._actualMarkerElement),e.has("interactive")&&this.updateInteractive(this._actualMarkerElement),e.has("active")&&(this.updateActive(this._actualMarkerElement),this.updateColor(this.markerContainer)),e.forEach((e,t)=>this._raisePropertyChange(t)),!1}updateVisibility(e){e&&(this.visible?e.removeAttribute("hidden"):e.setAttribute("hidden","true"))}getColor(){return this.color&&"unset"!==this.color?this.color:void 0}getActiveColor(){return this.activeColor&&"unset"!==this.activeColor?this.activeColor:void 0}updateColor(e){if(e){e.style.removeProperty(c),e.style.removeProperty(n);let t=this.getColor(),r=this.getActiveColor();t&&e.style.setProperty(c,t),r&&e.style.setProperty(n,r)}}updateActive(e){e&&(this.active?e.classList.add("active"):e.classList.remove("active"))}updateInteractive(e){e&&(this.interactive?e.classList.add("interactive"):e.classList.remove("interactive"))}refreshMarkerContent(){if(this.markerContainer){let e=this.createMarkerContent();e?this._actualMarkerElement.classList.remove("or-map-marker-default"):(this._actualMarkerElement.classList.add("or-map-marker-default"),e=this.createDefaultMarkerContent()),this.markerContainer.children.length>0&&this.markerContainer.removeChild(this.markerContainer.children[0]),this.markerContainer.appendChild(e)}}render(){return t`
69
- <slot></slot>
70
- `}_raisePropertyChange(e){this.dispatchEvent(new OrMapMarkerChangedEvent(this,e))}addMarkerClassNames(e){e.classList.add("or-map-marker")}addMarkerContainerClassNames(e){e.classList.add("marker-container")}createDefaultMarkerContent(){let e=document.createElement("div");return e.innerHTML=OrMapMarker_1._defaultTemplate(this.icon,{displayValue:this.displayValue,direction:this.direction}),e}hasPosition(){return"number"==typeof this.lat&&"number"==typeof this.lng&&this.lat>=-90&&this.lat<90&&this.lng>=-180&&this.lng<180}};OrMapMarker._defaultTemplate=(e,t)=>`
71
- ${t&&void 0!==t.displayValue?`<div class="label"><span>${t.displayValue}</span></div>`:""}
72
- ${t&&t.direction?`<div class="direction-icon-wrapper" style="transform: rotate(${t.direction}deg);">
73
- <svg class="direction-circle">
74
- <circle/>
75
- </svg>
76
- <or-icon class="direction-icon" icon="play"></or-icon>
77
- </div>`:""}
78
- <or-icon icon="or:marker"></or-icon>
79
- <or-icon class="marker-icon" icon="${e||""}"></or-icon>
80
- `,__decorate([o({type:Number,reflect:!0,attribute:!0})],OrMapMarker.prototype,"lat",void 0),__decorate([o({type:Number,reflect:!0})],OrMapMarker.prototype,"lng",void 0),__decorate([o({type:Number,reflect:!0})],OrMapMarker.prototype,"radius",void 0),__decorate([o({reflect:!0})],OrMapMarker.prototype,"displayValue",void 0),__decorate([o({reflect:!0})],OrMapMarker.prototype,"direction",void 0),__decorate([o({type:Boolean})],OrMapMarker.prototype,"visible",void 0),__decorate([o({type:String})],OrMapMarker.prototype,"icon",void 0),__decorate([o({type:String})],OrMapMarker.prototype,"color",void 0),__decorate([o({type:String})],OrMapMarker.prototype,"activeColor",void 0),__decorate([o({type:Boolean})],OrMapMarker.prototype,"interactive",void 0),__decorate([o({type:Boolean})],OrMapMarker.prototype,"active",void 0),__decorate([s("slot")],OrMapMarker.prototype,"_slot",void 0),OrMapMarker=OrMapMarker_1=__decorate([i("or-map-marker")],OrMapMarker);export{OrMapMarker};
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var OrMapMarker_1;
8
+ import { css, html, LitElement, unsafeCSS } from "lit";
9
+ import { customElement, property, query } from "lit/decorators.js";
10
+ import { markerActiveColorVar, markerColorVar } from "../style";
11
+ import { DefaultBoxShadow } from "@openremote/core";
12
+ export class OrMapMarkerChangedEvent extends CustomEvent {
13
+ constructor(marker, prop) {
14
+ super(OrMapMarkerChangedEvent.NAME, {
15
+ detail: {
16
+ marker: marker,
17
+ property: prop
18
+ },
19
+ bubbles: true,
20
+ composed: true
21
+ });
22
+ }
23
+ }
24
+ OrMapMarkerChangedEvent.NAME = "or-map-marker-changed";
25
+ export class OrMapMarkerClickedEvent extends CustomEvent {
26
+ constructor(marker) {
27
+ super(OrMapMarkerClickedEvent.NAME, {
28
+ detail: {
29
+ marker: marker
30
+ },
31
+ bubbles: true,
32
+ composed: true
33
+ });
34
+ }
35
+ }
36
+ OrMapMarkerClickedEvent.NAME = "or-map-marker-clicked";
37
+ /**
38
+ * Base class for all map markers.
39
+ *
40
+ * This component doesn't directly render anything instead it generates DOM that can be added to the map component
41
+ */
42
+ let OrMapMarker = OrMapMarker_1 = class OrMapMarker extends LitElement {
43
+ constructor() {
44
+ super(...arguments);
45
+ this.visible = true;
46
+ this.interactive = true;
47
+ this.active = false;
48
+ }
49
+ static get styles() {
50
+ return css `
51
+ .label {
52
+ background-color: white;
53
+ width: auto;
54
+ height: 20px;
55
+ position: absolute;
56
+ top: -14px;
57
+ left: 50%;
58
+ padding: 0 3px;
59
+ transform: translate(-50%, -50%);
60
+ text-align: center;
61
+ border-radius: 3px;
62
+ -webkit-box-shadow: ${unsafeCSS(DefaultBoxShadow)};
63
+ -moz-box-shadow: ${unsafeCSS(DefaultBoxShadow)};
64
+ box-shadow: ${unsafeCSS(DefaultBoxShadow)};
65
+ }
66
+ .label > span {
67
+ white-space: nowrap;
68
+ }
69
+
70
+ .direction-icon-wrapper {
71
+ position: absolute;
72
+ top: 11px;
73
+ left: 16px;
74
+ }
75
+ .direction-circle {
76
+ position: absolute;
77
+ margin-top: -15px;
78
+ margin-left: -15px;
79
+ width: 30px;
80
+ height: 30px;
81
+ }
82
+ .direction-circle circle {
83
+ cx: 15px;
84
+ cy: 15px;
85
+ r: 12px;
86
+ stroke: white;
87
+ stroke-width: 3px;
88
+ fill: transparent;
89
+ }
90
+ .direction-icon {
91
+ position: absolute;
92
+ top: -25px;
93
+ left: -16px;
94
+ transform: scale(0.75) rotate(-90deg);
95
+ }
96
+
97
+ .active .direction-icon-wrapper {
98
+ top: 17px;
99
+ left: 24px;
100
+ }
101
+ .active .direction-circle {
102
+ margin-top: -20px;
103
+ margin-left: -20px;
104
+ width: 40px;
105
+ height: 40px;
106
+ }
107
+ .active .direction-icon {
108
+ top: -36px;
109
+ left: -23px;
110
+ }
111
+ .active .direction-circle circle {
112
+ cx: 20px;
113
+ cy: 20px;
114
+ r: 18px;
115
+ stroke-width: 4px;
116
+ }
117
+ `;
118
+ }
119
+ get markerContainer() {
120
+ if (this._actualMarkerElement) {
121
+ return this._actualMarkerElement.firstElementChild;
122
+ }
123
+ }
124
+ _onClick(e) {
125
+ this.dispatchEvent(new OrMapMarkerClickedEvent(this));
126
+ }
127
+ _createMarkerElement() {
128
+ const markerElem = document.createElement("div");
129
+ const markerContainerElem = document.createElement("div");
130
+ markerElem.appendChild(markerContainerElem);
131
+ this.addMarkerClassNames(markerElem);
132
+ this.addMarkerContainerClassNames(markerContainerElem);
133
+ let content = this.createMarkerContent();
134
+ if (!content) {
135
+ // Append default marker
136
+ markerElem.classList.add("or-map-marker-default");
137
+ content = this.createDefaultMarkerContent();
138
+ }
139
+ markerContainerElem.appendChild(content);
140
+ this.updateInteractive(markerElem);
141
+ this.updateVisibility(markerElem);
142
+ this.updateColor(markerContainerElem);
143
+ this.updateActive(markerElem);
144
+ return markerElem;
145
+ }
146
+ /**
147
+ * Override in sub types to customise the look of the marker. If undefined returned then a default marker will
148
+ * be used instead.
149
+ */
150
+ createMarkerContent() {
151
+ // Append child elements
152
+ let hasChildren = false;
153
+ let container = document.createElement("div");
154
+ if (this._slot) {
155
+ this._slot.assignedNodes({ flatten: true }).forEach((child) => {
156
+ if (child instanceof HTMLElement) {
157
+ container.appendChild(child.cloneNode(true));
158
+ hasChildren = true;
159
+ }
160
+ });
161
+ }
162
+ if (!hasChildren) {
163
+ return;
164
+ }
165
+ return container;
166
+ }
167
+ shouldUpdate(_changedProperties) {
168
+ if (_changedProperties.has("icon") || _changedProperties.has("displayValue") || _changedProperties.has("direction")) {
169
+ this.refreshMarkerContent();
170
+ }
171
+ if (_changedProperties.has("color") || _changedProperties.has("activeColor")) {
172
+ this.updateColor(this.markerContainer);
173
+ }
174
+ if (_changedProperties.has("visible")) {
175
+ this.updateVisibility(this._actualMarkerElement);
176
+ }
177
+ if (_changedProperties.has("interactive")) {
178
+ this.updateInteractive(this._actualMarkerElement);
179
+ }
180
+ if (_changedProperties.has("active")) {
181
+ this.updateActive(this._actualMarkerElement);
182
+ this.updateColor(this.markerContainer);
183
+ }
184
+ _changedProperties.forEach((oldValue, prop) => this._raisePropertyChange(prop));
185
+ return false;
186
+ }
187
+ updateVisibility(container) {
188
+ if (container) {
189
+ if (this.visible) {
190
+ container.removeAttribute("hidden");
191
+ }
192
+ else {
193
+ container.setAttribute("hidden", "true");
194
+ }
195
+ }
196
+ }
197
+ getColor() {
198
+ return this.color && this.color !== "unset" ? this.color : undefined;
199
+ }
200
+ getActiveColor() {
201
+ return this.activeColor && this.activeColor !== "unset" ? this.activeColor : undefined;
202
+ }
203
+ updateColor(container) {
204
+ if (container) {
205
+ container.style.removeProperty(markerColorVar);
206
+ container.style.removeProperty(markerActiveColorVar);
207
+ const color = this.getColor();
208
+ const activeColor = this.getActiveColor();
209
+ if (color) {
210
+ container.style.setProperty(markerColorVar, color);
211
+ }
212
+ if (activeColor) {
213
+ container.style.setProperty(markerActiveColorVar, activeColor);
214
+ }
215
+ }
216
+ }
217
+ updateActive(container) {
218
+ if (container) {
219
+ if (this.active) {
220
+ container.classList.add("active");
221
+ }
222
+ else {
223
+ container.classList.remove("active");
224
+ }
225
+ }
226
+ }
227
+ updateInteractive(container) {
228
+ if (container) {
229
+ if (this.interactive) {
230
+ container.classList.add("interactive");
231
+ }
232
+ else {
233
+ container.classList.remove("interactive");
234
+ }
235
+ }
236
+ }
237
+ refreshMarkerContent() {
238
+ if (this.markerContainer) {
239
+ let content = this.createMarkerContent();
240
+ if (!content) {
241
+ // Append default marker
242
+ this._actualMarkerElement.classList.add("or-map-marker-default");
243
+ content = this.createDefaultMarkerContent();
244
+ }
245
+ else {
246
+ this._actualMarkerElement.classList.remove("or-map-marker-default");
247
+ }
248
+ if (this.markerContainer.children.length > 0) {
249
+ this.markerContainer.removeChild(this.markerContainer.children[0]);
250
+ }
251
+ this.markerContainer.appendChild(content);
252
+ }
253
+ }
254
+ render() {
255
+ return html `
256
+ <slot></slot>
257
+ `;
258
+ }
259
+ _raisePropertyChange(prop) {
260
+ this.dispatchEvent(new OrMapMarkerChangedEvent(this, prop));
261
+ }
262
+ addMarkerClassNames(markerElement) {
263
+ markerElement.classList.add("or-map-marker");
264
+ }
265
+ addMarkerContainerClassNames(markerContainer) {
266
+ markerContainer.classList.add("marker-container");
267
+ }
268
+ createDefaultMarkerContent() {
269
+ const div = document.createElement("div");
270
+ div.innerHTML = OrMapMarker_1._defaultTemplate(this.icon, { displayValue: this.displayValue, direction: this.direction });
271
+ return div;
272
+ }
273
+ hasPosition() {
274
+ return typeof this.lat === "number"
275
+ && typeof this.lng === "number"
276
+ && this.lat >= -90 && this.lat < 90
277
+ && this.lng >= -180 && this.lng < 180;
278
+ }
279
+ };
280
+ OrMapMarker._defaultTemplate = (icon, options) => `
281
+ ${options && options.displayValue !== undefined
282
+ ? `<div class="label"><span>${options.displayValue}</span></div>`
283
+ : ``}
284
+ ${options && options.direction
285
+ ? `<div class="direction-icon-wrapper" style="transform: rotate(${options.direction}deg);">
286
+ <svg class="direction-circle">
287
+ <circle/>
288
+ </svg>
289
+ <or-icon class="direction-icon" icon="play"></or-icon>
290
+ </div>`
291
+ : ``}
292
+ <or-icon icon="or:marker"></or-icon>
293
+ <or-icon class="marker-icon" icon="${icon || ""}"></or-icon>
294
+ `;
295
+ __decorate([
296
+ property({ type: Number, reflect: true, attribute: true })
297
+ ], OrMapMarker.prototype, "lat", void 0);
298
+ __decorate([
299
+ property({ type: Number, reflect: true })
300
+ ], OrMapMarker.prototype, "lng", void 0);
301
+ __decorate([
302
+ property({ type: Number, reflect: true })
303
+ ], OrMapMarker.prototype, "radius", void 0);
304
+ __decorate([
305
+ property({ reflect: true })
306
+ ], OrMapMarker.prototype, "displayValue", void 0);
307
+ __decorate([
308
+ property({ reflect: true })
309
+ ], OrMapMarker.prototype, "direction", void 0);
310
+ __decorate([
311
+ property({ type: Boolean })
312
+ ], OrMapMarker.prototype, "visible", void 0);
313
+ __decorate([
314
+ property({ type: String })
315
+ ], OrMapMarker.prototype, "icon", void 0);
316
+ __decorate([
317
+ property({ type: String })
318
+ ], OrMapMarker.prototype, "color", void 0);
319
+ __decorate([
320
+ property({ type: String })
321
+ ], OrMapMarker.prototype, "activeColor", void 0);
322
+ __decorate([
323
+ property({ type: Boolean })
324
+ ], OrMapMarker.prototype, "interactive", void 0);
325
+ __decorate([
326
+ property({ type: Boolean })
327
+ ], OrMapMarker.prototype, "active", void 0);
328
+ __decorate([
329
+ query("slot")
330
+ ], OrMapMarker.prototype, "_slot", void 0);
331
+ OrMapMarker = OrMapMarker_1 = __decorate([
332
+ customElement("or-map-marker")
333
+ ], OrMapMarker);
334
+ export { OrMapMarker };
335
+ //# sourceMappingURL=or-map-marker.js.map