@openremote/or-map 1.8.0-snapshot.20250725070921 → 1.8.0-snapshot.20250725120000
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/@types/maplibre-gl-geocoder.d.ts +2 -2
- package/README.md +113 -113
- package/dist/umd/index.bundle.js +915 -915
- package/dist/umd/index.bundle.js.map +1 -1
- package/dist/umd/index.js +915 -915
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.orbundle.js +974 -974
- package/dist/umd/index.orbundle.js.map +1 -1
- package/lib/index.js +519 -39
- package/lib/mapbox-url-utils.js +66 -1
- package/lib/mapwidget.js +885 -1
- package/lib/markers/or-map-marker-asset.js +178 -1
- package/lib/markers/or-map-marker.js +335 -80
- package/lib/or-map-asset-card.js +167 -18
- package/lib/style.js +242 -235
- package/lib/util.js +100 -1
- package/package.json +8 -8
|
@@ -1 +1,178 @@
|
|
|
1
|
-
var __decorate
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|