@deepfuture/dui-map 1.1.0
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/README.md +214 -0
- package/cluster-layer/index.d.ts +2 -0
- package/cluster-layer/index.js +2 -0
- package/cluster-layer/map-cluster-layer.d.ts +53 -0
- package/cluster-layer/map-cluster-layer.js +337 -0
- package/controls/index.d.ts +2 -0
- package/controls/index.js +2 -0
- package/controls/map-controls.d.ts +37 -0
- package/controls/map-controls.js +344 -0
- package/heatmap/index.d.ts +2 -0
- package/heatmap/index.js +2 -0
- package/heatmap/map-heatmap.d.ts +39 -0
- package/heatmap/map-heatmap.js +330 -0
- package/index.d.ts +10 -0
- package/index.js +9 -0
- package/map/index.d.ts +5 -0
- package/map/index.js +3 -0
- package/map/map-context.d.ts +8 -0
- package/map/map-context.js +2 -0
- package/map/map.d.ts +120 -0
- package/map/map.js +628 -0
- package/marker/index.d.ts +9 -0
- package/marker/index.js +7 -0
- package/marker/map-marker-content.d.ts +20 -0
- package/marker/map-marker-content.js +135 -0
- package/marker/map-marker-label.d.ts +21 -0
- package/marker/map-marker-label.js +126 -0
- package/marker/map-marker-popup.d.ts +25 -0
- package/marker/map-marker-popup.js +158 -0
- package/marker/map-marker-tooltip.d.ts +22 -0
- package/marker/map-marker-tooltip.js +159 -0
- package/marker/map-marker.d.ts +48 -0
- package/marker/map-marker.js +220 -0
- package/marker/marker-context.d.ts +8 -0
- package/marker/marker-context.js +2 -0
- package/package.json +70 -0
- package/popup/index.d.ts +2 -0
- package/popup/index.js +2 -0
- package/popup/map-popup.d.ts +29 -0
- package/popup/map-popup.js +184 -0
- package/region/index.d.ts +2 -0
- package/region/index.js +2 -0
- package/region/map-region.d.ts +41 -0
- package/region/map-region.js +276 -0
- package/route/index.d.ts +2 -0
- package/route/index.js +2 -0
- package/route/map-route.d.ts +33 -0
- package/route/map-route.js +245 -0
- package/theme/map-theme.d.ts +16 -0
- package/theme/map-theme.js +233 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { css, LitElement, html } from "lit";
|
|
36
|
+
import { property } from "lit/decorators.js";
|
|
37
|
+
import { consume } from "@lit/context";
|
|
38
|
+
import { base } from "@deepfuture/dui-primitives/core/base";
|
|
39
|
+
import { customEvent } from "@deepfuture/dui-primitives/core/event";
|
|
40
|
+
import MapLibreGL from "maplibre-gl";
|
|
41
|
+
import { mapContext } from "../map/map-context.js";
|
|
42
|
+
/** Fired when the popup is closed. */
|
|
43
|
+
export const popupCloseEvent = customEvent("dui-map-popup-close", { bubbles: true, composed: true });
|
|
44
|
+
const styles = css `
|
|
45
|
+
:host {
|
|
46
|
+
display: contents;
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
/**
|
|
50
|
+
* `<dui-map-popup>` — Standalone popup at coordinates on the map.
|
|
51
|
+
*
|
|
52
|
+
* @slot - Popup content.
|
|
53
|
+
* @csspart popup - The popup content wrapper.
|
|
54
|
+
* @fires dui-map-popup-close - Fired when the popup is closed.
|
|
55
|
+
*/
|
|
56
|
+
let DuiMapPopup = (() => {
|
|
57
|
+
let _classSuper = LitElement;
|
|
58
|
+
let _longitude_decorators;
|
|
59
|
+
let _longitude_initializers = [];
|
|
60
|
+
let _longitude_extraInitializers = [];
|
|
61
|
+
let _latitude_decorators;
|
|
62
|
+
let _latitude_initializers = [];
|
|
63
|
+
let _latitude_extraInitializers = [];
|
|
64
|
+
let _popupOffset_decorators;
|
|
65
|
+
let _popupOffset_initializers = [];
|
|
66
|
+
let _popupOffset_extraInitializers = [];
|
|
67
|
+
let _closeButton_decorators;
|
|
68
|
+
let _closeButton_initializers = [];
|
|
69
|
+
let _closeButton_extraInitializers = [];
|
|
70
|
+
let __mapCtx_decorators;
|
|
71
|
+
let __mapCtx_initializers = [];
|
|
72
|
+
let __mapCtx_extraInitializers = [];
|
|
73
|
+
return class DuiMapPopup extends _classSuper {
|
|
74
|
+
static {
|
|
75
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
76
|
+
_longitude_decorators = [property({ type: Number })];
|
|
77
|
+
_latitude_decorators = [property({ type: Number })];
|
|
78
|
+
_popupOffset_decorators = [property({ type: Number, attribute: "popup-offset" })];
|
|
79
|
+
_closeButton_decorators = [property({ type: Boolean, attribute: "close-button" })];
|
|
80
|
+
__mapCtx_decorators = [consume({ context: mapContext, subscribe: true })];
|
|
81
|
+
__esDecorate(this, null, _longitude_decorators, { kind: "accessor", name: "longitude", static: false, private: false, access: { has: obj => "longitude" in obj, get: obj => obj.longitude, set: (obj, value) => { obj.longitude = value; } }, metadata: _metadata }, _longitude_initializers, _longitude_extraInitializers);
|
|
82
|
+
__esDecorate(this, null, _latitude_decorators, { kind: "accessor", name: "latitude", static: false, private: false, access: { has: obj => "latitude" in obj, get: obj => obj.latitude, set: (obj, value) => { obj.latitude = value; } }, metadata: _metadata }, _latitude_initializers, _latitude_extraInitializers);
|
|
83
|
+
__esDecorate(this, null, _popupOffset_decorators, { kind: "accessor", name: "popupOffset", static: false, private: false, access: { has: obj => "popupOffset" in obj, get: obj => obj.popupOffset, set: (obj, value) => { obj.popupOffset = value; } }, metadata: _metadata }, _popupOffset_initializers, _popupOffset_extraInitializers);
|
|
84
|
+
__esDecorate(this, null, _closeButton_decorators, { kind: "accessor", name: "closeButton", static: false, private: false, access: { has: obj => "closeButton" in obj, get: obj => obj.closeButton, set: (obj, value) => { obj.closeButton = value; } }, metadata: _metadata }, _closeButton_initializers, _closeButton_extraInitializers);
|
|
85
|
+
__esDecorate(this, null, __mapCtx_decorators, { kind: "accessor", name: "_mapCtx", static: false, private: false, access: { has: obj => "_mapCtx" in obj, get: obj => obj._mapCtx, set: (obj, value) => { obj._mapCtx = value; } }, metadata: _metadata }, __mapCtx_initializers, __mapCtx_extraInitializers);
|
|
86
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
87
|
+
}
|
|
88
|
+
static tagName = "dui-map-popup";
|
|
89
|
+
static styles = [base, styles];
|
|
90
|
+
#longitude_accessor_storage = __runInitializers(this, _longitude_initializers, 0);
|
|
91
|
+
/** Longitude coordinate for popup position. */
|
|
92
|
+
get longitude() { return this.#longitude_accessor_storage; }
|
|
93
|
+
set longitude(value) { this.#longitude_accessor_storage = value; }
|
|
94
|
+
#latitude_accessor_storage = (__runInitializers(this, _longitude_extraInitializers), __runInitializers(this, _latitude_initializers, 0));
|
|
95
|
+
/** Latitude coordinate for popup position. */
|
|
96
|
+
get latitude() { return this.#latitude_accessor_storage; }
|
|
97
|
+
set latitude(value) { this.#latitude_accessor_storage = value; }
|
|
98
|
+
#popupOffset_accessor_storage = (__runInitializers(this, _latitude_extraInitializers), __runInitializers(this, _popupOffset_initializers, 16));
|
|
99
|
+
/** Popup offset from the anchor in pixels. */
|
|
100
|
+
get popupOffset() { return this.#popupOffset_accessor_storage; }
|
|
101
|
+
set popupOffset(value) { this.#popupOffset_accessor_storage = value; }
|
|
102
|
+
#closeButton_accessor_storage = (__runInitializers(this, _popupOffset_extraInitializers), __runInitializers(this, _closeButton_initializers, false));
|
|
103
|
+
/** Show a close button. */
|
|
104
|
+
get closeButton() { return this.#closeButton_accessor_storage; }
|
|
105
|
+
set closeButton(value) { this.#closeButton_accessor_storage = value; }
|
|
106
|
+
#_mapCtx_accessor_storage = (__runInitializers(this, _closeButton_extraInitializers), __runInitializers(this, __mapCtx_initializers, void 0));
|
|
107
|
+
get _mapCtx() { return this.#_mapCtx_accessor_storage; }
|
|
108
|
+
set _mapCtx(value) { this.#_mapCtx_accessor_storage = value; }
|
|
109
|
+
#popup = (__runInitializers(this, __mapCtx_extraInitializers), null);
|
|
110
|
+
#container = document.createElement("div");
|
|
111
|
+
#addedToMap = false;
|
|
112
|
+
connectedCallback() {
|
|
113
|
+
super.connectedCallback();
|
|
114
|
+
this.#popup = new MapLibreGL.Popup({
|
|
115
|
+
offset: this.popupOffset,
|
|
116
|
+
closeButton: false,
|
|
117
|
+
className: "dui-popup",
|
|
118
|
+
})
|
|
119
|
+
.setMaxWidth("none")
|
|
120
|
+
.setLngLat([this.longitude, this.latitude]);
|
|
121
|
+
}
|
|
122
|
+
disconnectedCallback() {
|
|
123
|
+
super.disconnectedCallback();
|
|
124
|
+
this.#popup?.remove();
|
|
125
|
+
this.#popup = null;
|
|
126
|
+
this.#addedToMap = false;
|
|
127
|
+
}
|
|
128
|
+
updated() {
|
|
129
|
+
const map = this._mapCtx?.map;
|
|
130
|
+
if (!map || !this.#popup)
|
|
131
|
+
return;
|
|
132
|
+
if (!this.#addedToMap) {
|
|
133
|
+
this.#popup.on("close", () => {
|
|
134
|
+
this.dispatchEvent(popupCloseEvent());
|
|
135
|
+
});
|
|
136
|
+
this.#popup.setDOMContent(this.#container);
|
|
137
|
+
this.#popup.addTo(map);
|
|
138
|
+
this.#addedToMap = true;
|
|
139
|
+
}
|
|
140
|
+
// Update position
|
|
141
|
+
if (this.#popup.isOpen()) {
|
|
142
|
+
const ll = this.#popup.getLngLat();
|
|
143
|
+
if (ll.lng !== this.longitude || ll.lat !== this.latitude) {
|
|
144
|
+
this.#popup.setLngLat([this.longitude, this.latitude]);
|
|
145
|
+
}
|
|
146
|
+
// Update offset
|
|
147
|
+
if (this.#popup.options?.offset !== this.popupOffset) {
|
|
148
|
+
this.#popup.setOffset(this.popupOffset);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this.#renderIntoPortal();
|
|
152
|
+
}
|
|
153
|
+
#handleClose = () => {
|
|
154
|
+
this.#popup?.remove();
|
|
155
|
+
};
|
|
156
|
+
#renderIntoPortal() {
|
|
157
|
+
const slot = this.shadowRoot.querySelector("slot");
|
|
158
|
+
if (!slot)
|
|
159
|
+
return;
|
|
160
|
+
const assigned = slot.assignedNodes({ flatten: true });
|
|
161
|
+
this.#container.innerHTML = "";
|
|
162
|
+
const wrapper = document.createElement("div");
|
|
163
|
+
wrapper.setAttribute("part", "popup");
|
|
164
|
+
if (this.closeButton) {
|
|
165
|
+
const btn = document.createElement("button");
|
|
166
|
+
btn.setAttribute("aria-label", "Close popup");
|
|
167
|
+
btn.type = "button";
|
|
168
|
+
btn.innerHTML = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;
|
|
169
|
+
btn.style.cssText = "position:absolute;top:4px;right:4px;z-index:10;background:none;border:none;cursor:pointer;padding:2px;opacity:0.7;color:inherit;";
|
|
170
|
+
btn.addEventListener("click", this.#handleClose);
|
|
171
|
+
wrapper.appendChild(btn);
|
|
172
|
+
}
|
|
173
|
+
for (const node of assigned) {
|
|
174
|
+
wrapper.appendChild(node.cloneNode(true));
|
|
175
|
+
}
|
|
176
|
+
this.#container.appendChild(wrapper);
|
|
177
|
+
}
|
|
178
|
+
render() {
|
|
179
|
+
return html `<slot style="display:none" @slotchange=${this.#renderIntoPortal}></slot>`;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
})();
|
|
183
|
+
export { DuiMapPopup };
|
|
184
|
+
customElements.define(DuiMapPopup.tagName, DuiMapPopup);
|
package/region/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type TemplateResult } from "lit";
|
|
2
|
+
import { type MapContext } from "../map/map-context.js";
|
|
3
|
+
/** Fired when the region is clicked. */
|
|
4
|
+
export declare const regionClickEvent: (detail: void) => CustomEvent<void>;
|
|
5
|
+
/**
|
|
6
|
+
* `<dui-map-region>` — GeoJSON polygon fill layer on the map.
|
|
7
|
+
*
|
|
8
|
+
* Renders filled polygon or multi-polygon regions with an optional border stroke.
|
|
9
|
+
* Accepts inline GeoJSON data or a URL to fetch from.
|
|
10
|
+
*
|
|
11
|
+
* @fires dui-region-click - Fired when the region is clicked.
|
|
12
|
+
*/
|
|
13
|
+
export declare class DuiMapRegion extends LitElement {
|
|
14
|
+
#private;
|
|
15
|
+
static tagName: "dui-map-region";
|
|
16
|
+
static styles: import("lit").CSSResult[];
|
|
17
|
+
/** Unique identifier. Auto-generated if not set. */
|
|
18
|
+
accessor regionId: string;
|
|
19
|
+
/**
|
|
20
|
+
* GeoJSON data — a URL string, a `Feature`, or a `FeatureCollection`
|
|
21
|
+
* containing Polygon or MultiPolygon geometries.
|
|
22
|
+
*/
|
|
23
|
+
accessor data: string | GeoJSON.Feature | GeoJSON.FeatureCollection;
|
|
24
|
+
/** Fill color. */
|
|
25
|
+
accessor fillColor: string;
|
|
26
|
+
/** Fill opacity (0–1). */
|
|
27
|
+
accessor fillOpacity: number;
|
|
28
|
+
/** Border stroke color. */
|
|
29
|
+
accessor strokeColor: string;
|
|
30
|
+
/** Border stroke width in pixels. Set to 0 to hide the border. */
|
|
31
|
+
accessor strokeWidth: number;
|
|
32
|
+
/** Border stroke opacity (0–1). */
|
|
33
|
+
accessor strokeOpacity: number;
|
|
34
|
+
/** Whether the region is interactive (pointer cursor + click events). */
|
|
35
|
+
accessor interactive: boolean;
|
|
36
|
+
accessor _mapCtx: MapContext;
|
|
37
|
+
connectedCallback(): void;
|
|
38
|
+
disconnectedCallback(): void;
|
|
39
|
+
updated(changed: PropertyValues): void;
|
|
40
|
+
render(): TemplateResult;
|
|
41
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { css, LitElement, html } from "lit";
|
|
36
|
+
import { property } from "lit/decorators.js";
|
|
37
|
+
import { consume } from "@lit/context";
|
|
38
|
+
import { base } from "@deepfuture/dui-primitives/core/base";
|
|
39
|
+
import { customEvent } from "@deepfuture/dui-primitives/core/event";
|
|
40
|
+
import { mapContext } from "../map/map-context.js";
|
|
41
|
+
/** Fired when the region is clicked. */
|
|
42
|
+
export const regionClickEvent = customEvent("dui-region-click", { bubbles: true, composed: true });
|
|
43
|
+
const styles = css `
|
|
44
|
+
:host {
|
|
45
|
+
display: contents;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* `<dui-map-region>` — GeoJSON polygon fill layer on the map.
|
|
50
|
+
*
|
|
51
|
+
* Renders filled polygon or multi-polygon regions with an optional border stroke.
|
|
52
|
+
* Accepts inline GeoJSON data or a URL to fetch from.
|
|
53
|
+
*
|
|
54
|
+
* @fires dui-region-click - Fired when the region is clicked.
|
|
55
|
+
*/
|
|
56
|
+
let DuiMapRegion = (() => {
|
|
57
|
+
let _classSuper = LitElement;
|
|
58
|
+
let _regionId_decorators;
|
|
59
|
+
let _regionId_initializers = [];
|
|
60
|
+
let _regionId_extraInitializers = [];
|
|
61
|
+
let _data_decorators;
|
|
62
|
+
let _data_initializers = [];
|
|
63
|
+
let _data_extraInitializers = [];
|
|
64
|
+
let _fillColor_decorators;
|
|
65
|
+
let _fillColor_initializers = [];
|
|
66
|
+
let _fillColor_extraInitializers = [];
|
|
67
|
+
let _fillOpacity_decorators;
|
|
68
|
+
let _fillOpacity_initializers = [];
|
|
69
|
+
let _fillOpacity_extraInitializers = [];
|
|
70
|
+
let _strokeColor_decorators;
|
|
71
|
+
let _strokeColor_initializers = [];
|
|
72
|
+
let _strokeColor_extraInitializers = [];
|
|
73
|
+
let _strokeWidth_decorators;
|
|
74
|
+
let _strokeWidth_initializers = [];
|
|
75
|
+
let _strokeWidth_extraInitializers = [];
|
|
76
|
+
let _strokeOpacity_decorators;
|
|
77
|
+
let _strokeOpacity_initializers = [];
|
|
78
|
+
let _strokeOpacity_extraInitializers = [];
|
|
79
|
+
let _interactive_decorators;
|
|
80
|
+
let _interactive_initializers = [];
|
|
81
|
+
let _interactive_extraInitializers = [];
|
|
82
|
+
let __mapCtx_decorators;
|
|
83
|
+
let __mapCtx_initializers = [];
|
|
84
|
+
let __mapCtx_extraInitializers = [];
|
|
85
|
+
return class DuiMapRegion extends _classSuper {
|
|
86
|
+
static {
|
|
87
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
88
|
+
_regionId_decorators = [property({ attribute: "region-id" })];
|
|
89
|
+
_data_decorators = [property({
|
|
90
|
+
converter: {
|
|
91
|
+
fromAttribute(value) {
|
|
92
|
+
if (!value)
|
|
93
|
+
return "";
|
|
94
|
+
try {
|
|
95
|
+
return JSON.parse(value);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
toAttribute(value) {
|
|
102
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
})];
|
|
106
|
+
_fillColor_decorators = [property({ attribute: "fill-color" })];
|
|
107
|
+
_fillOpacity_decorators = [property({ type: Number, attribute: "fill-opacity" })];
|
|
108
|
+
_strokeColor_decorators = [property({ attribute: "stroke-color" })];
|
|
109
|
+
_strokeWidth_decorators = [property({ type: Number, attribute: "stroke-width" })];
|
|
110
|
+
_strokeOpacity_decorators = [property({ type: Number, attribute: "stroke-opacity" })];
|
|
111
|
+
_interactive_decorators = [property({ type: Boolean })];
|
|
112
|
+
__mapCtx_decorators = [consume({ context: mapContext, subscribe: true })];
|
|
113
|
+
__esDecorate(this, null, _regionId_decorators, { kind: "accessor", name: "regionId", static: false, private: false, access: { has: obj => "regionId" in obj, get: obj => obj.regionId, set: (obj, value) => { obj.regionId = value; } }, metadata: _metadata }, _regionId_initializers, _regionId_extraInitializers);
|
|
114
|
+
__esDecorate(this, null, _data_decorators, { kind: "accessor", name: "data", static: false, private: false, access: { has: obj => "data" in obj, get: obj => obj.data, set: (obj, value) => { obj.data = value; } }, metadata: _metadata }, _data_initializers, _data_extraInitializers);
|
|
115
|
+
__esDecorate(this, null, _fillColor_decorators, { kind: "accessor", name: "fillColor", static: false, private: false, access: { has: obj => "fillColor" in obj, get: obj => obj.fillColor, set: (obj, value) => { obj.fillColor = value; } }, metadata: _metadata }, _fillColor_initializers, _fillColor_extraInitializers);
|
|
116
|
+
__esDecorate(this, null, _fillOpacity_decorators, { kind: "accessor", name: "fillOpacity", static: false, private: false, access: { has: obj => "fillOpacity" in obj, get: obj => obj.fillOpacity, set: (obj, value) => { obj.fillOpacity = value; } }, metadata: _metadata }, _fillOpacity_initializers, _fillOpacity_extraInitializers);
|
|
117
|
+
__esDecorate(this, null, _strokeColor_decorators, { kind: "accessor", name: "strokeColor", static: false, private: false, access: { has: obj => "strokeColor" in obj, get: obj => obj.strokeColor, set: (obj, value) => { obj.strokeColor = value; } }, metadata: _metadata }, _strokeColor_initializers, _strokeColor_extraInitializers);
|
|
118
|
+
__esDecorate(this, null, _strokeWidth_decorators, { kind: "accessor", name: "strokeWidth", static: false, private: false, access: { has: obj => "strokeWidth" in obj, get: obj => obj.strokeWidth, set: (obj, value) => { obj.strokeWidth = value; } }, metadata: _metadata }, _strokeWidth_initializers, _strokeWidth_extraInitializers);
|
|
119
|
+
__esDecorate(this, null, _strokeOpacity_decorators, { kind: "accessor", name: "strokeOpacity", static: false, private: false, access: { has: obj => "strokeOpacity" in obj, get: obj => obj.strokeOpacity, set: (obj, value) => { obj.strokeOpacity = value; } }, metadata: _metadata }, _strokeOpacity_initializers, _strokeOpacity_extraInitializers);
|
|
120
|
+
__esDecorate(this, null, _interactive_decorators, { kind: "accessor", name: "interactive", static: false, private: false, access: { has: obj => "interactive" in obj, get: obj => obj.interactive, set: (obj, value) => { obj.interactive = value; } }, metadata: _metadata }, _interactive_initializers, _interactive_extraInitializers);
|
|
121
|
+
__esDecorate(this, null, __mapCtx_decorators, { kind: "accessor", name: "_mapCtx", static: false, private: false, access: { has: obj => "_mapCtx" in obj, get: obj => obj._mapCtx, set: (obj, value) => { obj._mapCtx = value; } }, metadata: _metadata }, __mapCtx_initializers, __mapCtx_extraInitializers);
|
|
122
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
123
|
+
}
|
|
124
|
+
static tagName = "dui-map-region";
|
|
125
|
+
static styles = [base, styles];
|
|
126
|
+
#regionId_accessor_storage = __runInitializers(this, _regionId_initializers, `region-${Math.random().toString(36).slice(2, 9)}`);
|
|
127
|
+
/** Unique identifier. Auto-generated if not set. */
|
|
128
|
+
get regionId() { return this.#regionId_accessor_storage; }
|
|
129
|
+
set regionId(value) { this.#regionId_accessor_storage = value; }
|
|
130
|
+
#data_accessor_storage = (__runInitializers(this, _regionId_extraInitializers), __runInitializers(this, _data_initializers, ""));
|
|
131
|
+
/**
|
|
132
|
+
* GeoJSON data — a URL string, a `Feature`, or a `FeatureCollection`
|
|
133
|
+
* containing Polygon or MultiPolygon geometries.
|
|
134
|
+
*/
|
|
135
|
+
get data() { return this.#data_accessor_storage; }
|
|
136
|
+
set data(value) { this.#data_accessor_storage = value; }
|
|
137
|
+
#fillColor_accessor_storage = (__runInitializers(this, _data_extraInitializers), __runInitializers(this, _fillColor_initializers, "rgba(59, 130, 246, 0.3)"));
|
|
138
|
+
/** Fill color. */
|
|
139
|
+
get fillColor() { return this.#fillColor_accessor_storage; }
|
|
140
|
+
set fillColor(value) { this.#fillColor_accessor_storage = value; }
|
|
141
|
+
#fillOpacity_accessor_storage = (__runInitializers(this, _fillColor_extraInitializers), __runInitializers(this, _fillOpacity_initializers, 1));
|
|
142
|
+
/** Fill opacity (0–1). */
|
|
143
|
+
get fillOpacity() { return this.#fillOpacity_accessor_storage; }
|
|
144
|
+
set fillOpacity(value) { this.#fillOpacity_accessor_storage = value; }
|
|
145
|
+
#strokeColor_accessor_storage = (__runInitializers(this, _fillOpacity_extraInitializers), __runInitializers(this, _strokeColor_initializers, "#3b82f6"));
|
|
146
|
+
/** Border stroke color. */
|
|
147
|
+
get strokeColor() { return this.#strokeColor_accessor_storage; }
|
|
148
|
+
set strokeColor(value) { this.#strokeColor_accessor_storage = value; }
|
|
149
|
+
#strokeWidth_accessor_storage = (__runInitializers(this, _strokeColor_extraInitializers), __runInitializers(this, _strokeWidth_initializers, 2));
|
|
150
|
+
/** Border stroke width in pixels. Set to 0 to hide the border. */
|
|
151
|
+
get strokeWidth() { return this.#strokeWidth_accessor_storage; }
|
|
152
|
+
set strokeWidth(value) { this.#strokeWidth_accessor_storage = value; }
|
|
153
|
+
#strokeOpacity_accessor_storage = (__runInitializers(this, _strokeWidth_extraInitializers), __runInitializers(this, _strokeOpacity_initializers, 1));
|
|
154
|
+
/** Border stroke opacity (0–1). */
|
|
155
|
+
get strokeOpacity() { return this.#strokeOpacity_accessor_storage; }
|
|
156
|
+
set strokeOpacity(value) { this.#strokeOpacity_accessor_storage = value; }
|
|
157
|
+
#interactive_accessor_storage = (__runInitializers(this, _strokeOpacity_extraInitializers), __runInitializers(this, _interactive_initializers, true));
|
|
158
|
+
/** Whether the region is interactive (pointer cursor + click events). */
|
|
159
|
+
get interactive() { return this.#interactive_accessor_storage; }
|
|
160
|
+
set interactive(value) { this.#interactive_accessor_storage = value; }
|
|
161
|
+
#_mapCtx_accessor_storage = (__runInitializers(this, _interactive_extraInitializers), __runInitializers(this, __mapCtx_initializers, void 0));
|
|
162
|
+
get _mapCtx() { return this.#_mapCtx_accessor_storage; }
|
|
163
|
+
set _mapCtx(value) { this.#_mapCtx_accessor_storage = value; }
|
|
164
|
+
#sourceId = (__runInitializers(this, __mapCtx_extraInitializers), "");
|
|
165
|
+
#fillLayerId = "";
|
|
166
|
+
#strokeLayerId = "";
|
|
167
|
+
#layersAdded = false;
|
|
168
|
+
connectedCallback() {
|
|
169
|
+
super.connectedCallback();
|
|
170
|
+
this.#sourceId = `region-source-${this.regionId}`;
|
|
171
|
+
this.#fillLayerId = `region-fill-${this.regionId}`;
|
|
172
|
+
this.#strokeLayerId = `region-stroke-${this.regionId}`;
|
|
173
|
+
}
|
|
174
|
+
disconnectedCallback() {
|
|
175
|
+
super.disconnectedCallback();
|
|
176
|
+
this.#removeLayers();
|
|
177
|
+
}
|
|
178
|
+
updated(changed) {
|
|
179
|
+
const map = this._mapCtx?.map;
|
|
180
|
+
const isLoaded = this._mapCtx?.isLoaded;
|
|
181
|
+
if (!map || !isLoaded)
|
|
182
|
+
return;
|
|
183
|
+
if (!this.#layersAdded) {
|
|
184
|
+
this.#addLayers(map);
|
|
185
|
+
}
|
|
186
|
+
// Update data (inline GeoJSON or URL string)
|
|
187
|
+
if (changed.has("data") && this.data) {
|
|
188
|
+
const source = map.getSource(this.#sourceId);
|
|
189
|
+
if (source) {
|
|
190
|
+
source.setData(this.data);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Update paint properties
|
|
194
|
+
if (changed.has("fillColor") || changed.has("fillOpacity")) {
|
|
195
|
+
if (map.getLayer(this.#fillLayerId)) {
|
|
196
|
+
map.setPaintProperty(this.#fillLayerId, "fill-color", this.fillColor);
|
|
197
|
+
map.setPaintProperty(this.#fillLayerId, "fill-opacity", this.fillOpacity);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (changed.has("strokeColor") || changed.has("strokeWidth") || changed.has("strokeOpacity")) {
|
|
201
|
+
if (map.getLayer(this.#strokeLayerId)) {
|
|
202
|
+
map.setPaintProperty(this.#strokeLayerId, "line-color", this.strokeColor);
|
|
203
|
+
map.setPaintProperty(this.#strokeLayerId, "line-width", this.strokeWidth);
|
|
204
|
+
map.setPaintProperty(this.#strokeLayerId, "line-opacity", this.strokeOpacity);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
#addLayers(map) {
|
|
209
|
+
if (map.getSource(this.#sourceId))
|
|
210
|
+
return;
|
|
211
|
+
// Determine initial data — URL string vs inline GeoJSON
|
|
212
|
+
const initialData = this.data || { type: "FeatureCollection", features: [] };
|
|
213
|
+
map.addSource(this.#sourceId, {
|
|
214
|
+
type: "geojson",
|
|
215
|
+
data: initialData,
|
|
216
|
+
});
|
|
217
|
+
// Fill layer
|
|
218
|
+
map.addLayer({
|
|
219
|
+
id: this.#fillLayerId,
|
|
220
|
+
type: "fill",
|
|
221
|
+
source: this.#sourceId,
|
|
222
|
+
paint: {
|
|
223
|
+
"fill-color": this.fillColor,
|
|
224
|
+
"fill-opacity": this.fillOpacity,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
// Stroke layer
|
|
228
|
+
if (this.strokeWidth > 0) {
|
|
229
|
+
map.addLayer({
|
|
230
|
+
id: this.#strokeLayerId,
|
|
231
|
+
type: "line",
|
|
232
|
+
source: this.#sourceId,
|
|
233
|
+
paint: {
|
|
234
|
+
"line-color": this.strokeColor,
|
|
235
|
+
"line-width": this.strokeWidth,
|
|
236
|
+
"line-opacity": this.strokeOpacity,
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (this.interactive) {
|
|
241
|
+
map.on("click", this.#fillLayerId, () => {
|
|
242
|
+
this.dispatchEvent(regionClickEvent());
|
|
243
|
+
});
|
|
244
|
+
map.on("mouseenter", this.#fillLayerId, () => {
|
|
245
|
+
map.getCanvas().style.cursor = "pointer";
|
|
246
|
+
});
|
|
247
|
+
map.on("mouseleave", this.#fillLayerId, () => {
|
|
248
|
+
map.getCanvas().style.cursor = "";
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
this.#layersAdded = true;
|
|
252
|
+
}
|
|
253
|
+
#removeLayers() {
|
|
254
|
+
const map = this._mapCtx?.map;
|
|
255
|
+
if (!map)
|
|
256
|
+
return;
|
|
257
|
+
try {
|
|
258
|
+
if (map.getLayer(this.#strokeLayerId))
|
|
259
|
+
map.removeLayer(this.#strokeLayerId);
|
|
260
|
+
if (map.getLayer(this.#fillLayerId))
|
|
261
|
+
map.removeLayer(this.#fillLayerId);
|
|
262
|
+
if (map.getSource(this.#sourceId))
|
|
263
|
+
map.removeSource(this.#sourceId);
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// Map may already be destroyed
|
|
267
|
+
}
|
|
268
|
+
this.#layersAdded = false;
|
|
269
|
+
}
|
|
270
|
+
render() {
|
|
271
|
+
return html ``;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
})();
|
|
275
|
+
export { DuiMapRegion };
|
|
276
|
+
customElements.define(DuiMapRegion.tagName, DuiMapRegion);
|
package/route/index.d.ts
ADDED
package/route/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type TemplateResult } from "lit";
|
|
2
|
+
import { type MapContext } from "../map/map-context.js";
|
|
3
|
+
/** Fired when the route line is clicked. */
|
|
4
|
+
export declare const routeClickEvent: (detail: void) => CustomEvent<void>;
|
|
5
|
+
/**
|
|
6
|
+
* `<dui-map-route>` — GeoJSON LineString route layer on the map.
|
|
7
|
+
*
|
|
8
|
+
* @fires dui-route-click - Fired when the route line is clicked.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DuiMapRoute extends LitElement {
|
|
11
|
+
#private;
|
|
12
|
+
static tagName: "dui-map-route";
|
|
13
|
+
static styles: import("lit").CSSResult[];
|
|
14
|
+
/** Unique identifier for the route. Auto-generated if not set. */
|
|
15
|
+
accessor routeId: string;
|
|
16
|
+
/** Array of `[longitude, latitude]` coordinate pairs defining the route. */
|
|
17
|
+
accessor coordinates: [number, number][];
|
|
18
|
+
/** Line color as CSS color value. */
|
|
19
|
+
accessor color: string;
|
|
20
|
+
/** Line width in pixels. */
|
|
21
|
+
accessor width: number;
|
|
22
|
+
/** Line opacity from 0 to 1. */
|
|
23
|
+
accessor opacity: number;
|
|
24
|
+
/** Dash pattern `[dash, gap]` for dashed lines. */
|
|
25
|
+
accessor dashArray: [number, number] | undefined;
|
|
26
|
+
/** Whether the route is interactive (pointer cursor on hover). */
|
|
27
|
+
accessor interactive: boolean;
|
|
28
|
+
accessor _mapCtx: MapContext;
|
|
29
|
+
connectedCallback(): void;
|
|
30
|
+
disconnectedCallback(): void;
|
|
31
|
+
updated(changed: PropertyValues): void;
|
|
32
|
+
render(): TemplateResult;
|
|
33
|
+
}
|