@mcp-b/geo-leaflet 0.2.21 → 0.3.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.
@@ -1,190 +0,0 @@
1
- import { n as __toESM, t as require_leaflet_src } from "./leaflet-src-DkjKLRUt.js";
2
- import "./default-icon.js";
3
- import { t as __decorate } from "./decorate-DcF3lt7P.js";
4
- import { findLeafletMap } from "./components/find-leaflet-map.js";
5
- import { LitElement, css, html } from "lit";
6
- import { customElement, property } from "lit/decorators.js";
7
- import { SigveloFeatureClickEvent } from "@mcp-b/geo-support/events";
8
- import { subscribeClassify } from "@mcp-b/geo-support/classification";
9
- //#region src/components/geojson/geojson.styles.ts
10
- var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
11
- var geojson_styles_default = css`
12
- :host {
13
- display: none;
14
- }
15
- `;
16
- //#endregion
17
- //#region src/components/geojson/geojson.ts
18
- function formatPopupProperty(value) {
19
- if (typeof value === "string") return value;
20
- if (typeof value === "number") return Number.isFinite(value) ? value.toLocaleString(void 0, { maximumSignificantDigits: 4 }) : void 0;
21
- if (typeof value === "boolean") return value ? "Yes" : "No";
22
- }
23
- let SigveloLeafletGeojson = class SigveloLeafletGeojson extends LitElement {
24
- constructor(..._args) {
25
- super(..._args);
26
- this.data = null;
27
- this.styleFunction = null;
28
- this.fillColor = "#3388ff";
29
- this.fillOpacity = .2;
30
- this.strokeColor = "#3388ff";
31
- this.strokeWidth = 3;
32
- this.strokeOpacity = 1;
33
- this.interactive = true;
34
- this.popupTitleProperty = "";
35
- this.popupValueProperty = "";
36
- this.popupValueLabel = "";
37
- this.fitBounds = false;
38
- this.channel = "";
39
- this._layer = null;
40
- this._mapEl = null;
41
- this._unsubscribeChannel = null;
42
- }
43
- static {
44
- this.styles = [geojson_styles_default];
45
- }
46
- /** Access the underlying Leaflet GeoJSON layer. */
47
- get layer() {
48
- return this._layer;
49
- }
50
- async connectedCallback() {
51
- super.connectedCallback();
52
- this._subscribeChannel();
53
- this._mapEl = findLeafletMap(this);
54
- if (this._mapEl) {
55
- await this._mapEl.mapReady;
56
- if (!this.isConnected) return;
57
- this._addLayer();
58
- }
59
- }
60
- disconnectedCallback() {
61
- super.disconnectedCallback();
62
- this._unsubscribeChannel?.();
63
- this._unsubscribeChannel = null;
64
- this._removeLayer();
65
- }
66
- /** @internal */
67
- _subscribeChannel() {
68
- this._unsubscribeChannel?.();
69
- if (!this.channel) return;
70
- this._unsubscribeChannel = subscribeClassify(this.channel, (detail) => {
71
- this.styleFunction = detail.styleFunction;
72
- });
73
- }
74
- /** @internal */
75
- _toGeoJsonFeature(feature) {
76
- return {
77
- type: "Feature",
78
- geometry: feature.geometry,
79
- properties: feature.properties ?? null,
80
- id: feature.id
81
- };
82
- }
83
- /** @internal */
84
- _getStyleForFeature(feature) {
85
- if (this.styleFunction) {
86
- const s = this.styleFunction(this._toGeoJsonFeature(feature));
87
- if (s) return {
88
- fillColor: s.fillColor ?? this.fillColor,
89
- fillOpacity: s.fillOpacity ?? this.fillOpacity,
90
- color: s.strokeColor ?? this.strokeColor,
91
- weight: s.strokeWidth ?? this.strokeWidth,
92
- opacity: s.strokeOpacity ?? this.strokeOpacity
93
- };
94
- }
95
- return {
96
- fillColor: this.fillColor,
97
- fillOpacity: this.fillOpacity,
98
- color: this.strokeColor,
99
- weight: this.strokeWidth,
100
- opacity: this.strokeOpacity
101
- };
102
- }
103
- /** @internal */
104
- _getPopupForFeature(feature) {
105
- if (!this.popupTitleProperty) return;
106
- const properties = feature.properties ?? {};
107
- const title = formatPopupProperty(properties[this.popupTitleProperty]);
108
- if (title === void 0) return;
109
- const content = document.createElement("div");
110
- const heading = document.createElement("strong");
111
- heading.textContent = title;
112
- content.appendChild(heading);
113
- if (this.popupValueProperty) {
114
- const value = formatPopupProperty(properties[this.popupValueProperty]);
115
- if (value !== void 0) {
116
- const detail = document.createElement("div");
117
- detail.textContent = this.popupValueLabel ? `${this.popupValueLabel}: ${value}` : value;
118
- content.appendChild(detail);
119
- }
120
- }
121
- return content;
122
- }
123
- /** @internal */
124
- _addLayer() {
125
- this._removeLayer();
126
- if (!this._mapEl?.map || !this.data) return;
127
- this._layer = import_leaflet_src.geoJSON(this.data, {
128
- style: (feature) => feature ? this._getStyleForFeature(feature) : {},
129
- interactive: this.interactive,
130
- onEachFeature: (feature, layer) => {
131
- const popup = this._getPopupForFeature(feature);
132
- if (popup) layer.bindPopup(popup);
133
- if (this.interactive) layer.on("click", (e) => {
134
- this.dispatchEvent(new SigveloFeatureClickEvent(this._toGeoJsonFeature(feature), {
135
- lat: e.latlng.lat,
136
- lng: e.latlng.lng
137
- }));
138
- });
139
- }
140
- }).addTo(this._mapEl.map);
141
- if (this.fitBounds && this._layer.getLayers().length > 0) {
142
- const bounds = this._layer.getBounds();
143
- if (bounds.isValid()) this._mapEl.map.fitBounds(bounds, { padding: [12, 12] });
144
- }
145
- }
146
- /** @internal */
147
- _removeLayer() {
148
- this._layer?.remove();
149
- this._layer = null;
150
- }
151
- updated(changed) {
152
- if (changed.has("data") || changed.has("interactive") || changed.has("popupTitleProperty") || changed.has("popupValueProperty") || changed.has("popupValueLabel")) this._addLayer();
153
- else if (changed.has("styleFunction") || changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth") || changed.has("strokeOpacity")) this._layer?.setStyle((feature) => feature ? this._getStyleForFeature(feature) : {});
154
- else if (changed.has("fitBounds") && this.fitBounds && this._layer && this._mapEl?.map) {
155
- const bounds = this._layer.getBounds();
156
- if (bounds.isValid()) this._mapEl.map.fitBounds(bounds, { padding: [12, 12] });
157
- }
158
- }
159
- render() {
160
- return html``;
161
- }
162
- };
163
- __decorate([property({ attribute: false })], SigveloLeafletGeojson.prototype, "data", void 0);
164
- __decorate([property({ attribute: false })], SigveloLeafletGeojson.prototype, "styleFunction", void 0);
165
- __decorate([property({ attribute: "fill-color" })], SigveloLeafletGeojson.prototype, "fillColor", void 0);
166
- __decorate([property({
167
- attribute: "fill-opacity",
168
- type: Number
169
- })], SigveloLeafletGeojson.prototype, "fillOpacity", void 0);
170
- __decorate([property({ attribute: "stroke-color" })], SigveloLeafletGeojson.prototype, "strokeColor", void 0);
171
- __decorate([property({
172
- attribute: "stroke-width",
173
- type: Number
174
- })], SigveloLeafletGeojson.prototype, "strokeWidth", void 0);
175
- __decorate([property({
176
- attribute: "stroke-opacity",
177
- type: Number
178
- })], SigveloLeafletGeojson.prototype, "strokeOpacity", void 0);
179
- __decorate([property({ type: Boolean })], SigveloLeafletGeojson.prototype, "interactive", void 0);
180
- __decorate([property({ attribute: "popup-title-property" })], SigveloLeafletGeojson.prototype, "popupTitleProperty", void 0);
181
- __decorate([property({ attribute: "popup-value-property" })], SigveloLeafletGeojson.prototype, "popupValueProperty", void 0);
182
- __decorate([property({ attribute: "popup-value-label" })], SigveloLeafletGeojson.prototype, "popupValueLabel", void 0);
183
- __decorate([property({
184
- attribute: "fit-bounds",
185
- type: Boolean
186
- })], SigveloLeafletGeojson.prototype, "fitBounds", void 0);
187
- __decorate([property()], SigveloLeafletGeojson.prototype, "channel", void 0);
188
- SigveloLeafletGeojson = __decorate([customElement("sigvelo-leaflet-geojson")], SigveloLeafletGeojson);
189
- //#endregion
190
- export { SigveloLeafletGeojson as t };
@@ -1,116 +0,0 @@
1
- import { n as __toESM, t as require_leaflet_src } from "./leaflet-src-DkjKLRUt.js";
2
- import "./default-icon.js";
3
- import { t as __decorate } from "./decorate-DcF3lt7P.js";
4
- import { findLeafletMap } from "./components/find-leaflet-map.js";
5
- import { LitElement, css, html } from "lit";
6
- import { customElement, property } from "lit/decorators.js";
7
- //#region src/components/marker/marker.styles.ts
8
- var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
9
- var marker_styles_default = css`
10
- :host {
11
- display: none;
12
- }
13
- `;
14
- //#endregion
15
- //#region src/components/marker/marker.ts
16
- let SigveloLeafletMarker = class SigveloLeafletMarker extends LitElement {
17
- constructor(..._args) {
18
- super(..._args);
19
- this.latitude = 0;
20
- this.longitude = 0;
21
- this.title = "";
22
- this.draggable = false;
23
- this.opacity = 1;
24
- this.iconUrl = "";
25
- this.iconWidth = 25;
26
- this.iconHeight = 41;
27
- this._marker = null;
28
- this._mapEl = null;
29
- }
30
- static {
31
- this.styles = [marker_styles_default];
32
- }
33
- /** Access the underlying Leaflet marker instance. */
34
- get marker() {
35
- return this._marker;
36
- }
37
- async connectedCallback() {
38
- super.connectedCallback();
39
- this._mapEl = findLeafletMap(this);
40
- if (this._mapEl) {
41
- await this._mapEl.mapReady;
42
- if (!this.isConnected) return;
43
- this._addMarker();
44
- }
45
- }
46
- disconnectedCallback() {
47
- super.disconnectedCallback();
48
- this._removeMarker();
49
- }
50
- /** @internal */
51
- _addMarker() {
52
- this._removeMarker();
53
- if (!this._mapEl?.map) return;
54
- const options = {
55
- title: this.title,
56
- draggable: this.draggable,
57
- opacity: this.opacity
58
- };
59
- if (this.iconUrl) options.icon = import_leaflet_src.icon({
60
- iconUrl: this.iconUrl,
61
- iconSize: [this.iconWidth, this.iconHeight],
62
- iconAnchor: [this.iconWidth / 2, this.iconHeight],
63
- popupAnchor: [0, -this.iconHeight]
64
- });
65
- this._marker = import_leaflet_src.marker([this.latitude, this.longitude], options).addTo(this._mapEl.map);
66
- this._bindChildPopup();
67
- this._marker.on("dragend", () => {
68
- if (!this._marker) return;
69
- const pos = this._marker.getLatLng();
70
- this.latitude = pos.lat;
71
- this.longitude = pos.lng;
72
- });
73
- }
74
- /** @internal */
75
- _removeMarker() {
76
- this._marker?.remove();
77
- this._marker = null;
78
- }
79
- /** @internal */
80
- _bindChildPopup() {
81
- if (!this._marker) return;
82
- const popupEl = this.querySelector("sigvelo-leaflet-popup");
83
- if (popupEl) {
84
- const content = document.createElement("div");
85
- content.append(...Array.from(popupEl.childNodes).map((n) => n.cloneNode(true)));
86
- this._marker.bindPopup(content);
87
- }
88
- }
89
- updated() {
90
- if (this._marker) {
91
- this._marker.setLatLng([this.latitude, this.longitude]);
92
- this._marker.setOpacity(this.opacity);
93
- this._bindChildPopup();
94
- }
95
- }
96
- render() {
97
- return html` <slot></slot> `;
98
- }
99
- };
100
- __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "latitude", void 0);
101
- __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "longitude", void 0);
102
- __decorate([property()], SigveloLeafletMarker.prototype, "title", void 0);
103
- __decorate([property({ type: Boolean })], SigveloLeafletMarker.prototype, "draggable", void 0);
104
- __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "opacity", void 0);
105
- __decorate([property({ attribute: "icon-url" })], SigveloLeafletMarker.prototype, "iconUrl", void 0);
106
- __decorate([property({
107
- attribute: "icon-width",
108
- type: Number
109
- })], SigveloLeafletMarker.prototype, "iconWidth", void 0);
110
- __decorate([property({
111
- attribute: "icon-height",
112
- type: Number
113
- })], SigveloLeafletMarker.prototype, "iconHeight", void 0);
114
- SigveloLeafletMarker = __decorate([customElement("sigvelo-leaflet-marker")], SigveloLeafletMarker);
115
- //#endregion
116
- export { SigveloLeafletMarker as t };
@@ -1,79 +0,0 @@
1
- import { n as __toESM, t as require_leaflet_src } from "./leaflet-src-DkjKLRUt.js";
2
- import { t as __decorate } from "./decorate-DcF3lt7P.js";
3
- import { findLeafletMap } from "./components/find-leaflet-map.js";
4
- import { LitElement, css, html } from "lit";
5
- import { customElement, property } from "lit/decorators.js";
6
- //#region src/components/polygon/polygon.styles.ts
7
- var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
8
- var polygon_styles_default = css`
9
- :host {
10
- display: none;
11
- }
12
- `;
13
- //#endregion
14
- //#region src/components/polygon/polygon.ts
15
- let SigveloLeafletPolygon = class SigveloLeafletPolygon extends LitElement {
16
- constructor(..._args) {
17
- super(..._args);
18
- this.positions = [];
19
- this.fillColor = "#3388ff";
20
- this.fillOpacity = .2;
21
- this.strokeColor = "#3388ff";
22
- this.strokeWidth = 3;
23
- this._polygon = null;
24
- this._mapEl = null;
25
- }
26
- static {
27
- this.styles = [polygon_styles_default];
28
- }
29
- async connectedCallback() {
30
- super.connectedCallback();
31
- this._mapEl = findLeafletMap(this);
32
- if (this._mapEl) {
33
- await this._mapEl.mapReady;
34
- this._addPolygon();
35
- }
36
- }
37
- disconnectedCallback() {
38
- super.disconnectedCallback();
39
- this._polygon?.remove();
40
- this._polygon = null;
41
- }
42
- /** @internal */
43
- _addPolygon() {
44
- if (!this._mapEl?.map) return;
45
- this._polygon = import_leaflet_src.polygon(this.positions, {
46
- fillColor: this.fillColor,
47
- fillOpacity: this.fillOpacity,
48
- color: this.strokeColor,
49
- weight: this.strokeWidth
50
- }).addTo(this._mapEl.map);
51
- }
52
- updated(changed) {
53
- if (!this._polygon) return;
54
- if (changed.has("positions")) this._polygon.setLatLngs(this.positions);
55
- if (changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth")) this._polygon.setStyle({
56
- fillColor: this.fillColor,
57
- fillOpacity: this.fillOpacity,
58
- color: this.strokeColor,
59
- weight: this.strokeWidth
60
- });
61
- }
62
- render() {
63
- return html``;
64
- }
65
- };
66
- __decorate([property({ attribute: false })], SigveloLeafletPolygon.prototype, "positions", void 0);
67
- __decorate([property({ attribute: "fill-color" })], SigveloLeafletPolygon.prototype, "fillColor", void 0);
68
- __decorate([property({
69
- attribute: "fill-opacity",
70
- type: Number
71
- })], SigveloLeafletPolygon.prototype, "fillOpacity", void 0);
72
- __decorate([property({ attribute: "stroke-color" })], SigveloLeafletPolygon.prototype, "strokeColor", void 0);
73
- __decorate([property({
74
- attribute: "stroke-width",
75
- type: Number
76
- })], SigveloLeafletPolygon.prototype, "strokeWidth", void 0);
77
- SigveloLeafletPolygon = __decorate([customElement("sigvelo-leaflet-polygon")], SigveloLeafletPolygon);
78
- //#endregion
79
- export { SigveloLeafletPolygon as t };
@@ -1,73 +0,0 @@
1
- import { n as __toESM, t as require_leaflet_src } from "./leaflet-src-DkjKLRUt.js";
2
- import { t as __decorate } from "./decorate-DcF3lt7P.js";
3
- import { findLeafletMap } from "./components/find-leaflet-map.js";
4
- import { LitElement, css, html } from "lit";
5
- import { customElement, property } from "lit/decorators.js";
6
- //#region src/components/polyline/polyline.styles.ts
7
- var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
8
- var polyline_styles_default = css`
9
- :host {
10
- display: none;
11
- }
12
- `;
13
- //#endregion
14
- //#region src/components/polyline/polyline.ts
15
- let SigveloLeafletPolyline = class SigveloLeafletPolyline extends LitElement {
16
- constructor(..._args) {
17
- super(..._args);
18
- this.positions = [];
19
- this.color = "#3388ff";
20
- this.weight = 3;
21
- this.opacity = 1;
22
- this.dashArray = "";
23
- this._polyline = null;
24
- this._mapEl = null;
25
- }
26
- static {
27
- this.styles = [polyline_styles_default];
28
- }
29
- async connectedCallback() {
30
- super.connectedCallback();
31
- this._mapEl = findLeafletMap(this);
32
- if (this._mapEl) {
33
- await this._mapEl.mapReady;
34
- this._addPolyline();
35
- }
36
- }
37
- disconnectedCallback() {
38
- super.disconnectedCallback();
39
- this._polyline?.remove();
40
- this._polyline = null;
41
- }
42
- /** @internal */
43
- _addPolyline() {
44
- if (!this._mapEl?.map) return;
45
- this._polyline = import_leaflet_src.polyline(this.positions, {
46
- color: this.color,
47
- weight: this.weight,
48
- opacity: this.opacity,
49
- dashArray: this.dashArray || void 0
50
- }).addTo(this._mapEl.map);
51
- }
52
- updated(changed) {
53
- if (!this._polyline) return;
54
- if (changed.has("positions")) this._polyline.setLatLngs(this.positions);
55
- if (changed.has("color") || changed.has("weight") || changed.has("opacity") || changed.has("dashArray")) this._polyline.setStyle({
56
- color: this.color,
57
- weight: this.weight,
58
- opacity: this.opacity,
59
- dashArray: this.dashArray || void 0
60
- });
61
- }
62
- render() {
63
- return html``;
64
- }
65
- };
66
- __decorate([property({ attribute: false })], SigveloLeafletPolyline.prototype, "positions", void 0);
67
- __decorate([property()], SigveloLeafletPolyline.prototype, "color", void 0);
68
- __decorate([property({ type: Number })], SigveloLeafletPolyline.prototype, "weight", void 0);
69
- __decorate([property({ type: Number })], SigveloLeafletPolyline.prototype, "opacity", void 0);
70
- __decorate([property({ attribute: "dash-array" })], SigveloLeafletPolyline.prototype, "dashArray", void 0);
71
- SigveloLeafletPolyline = __decorate([customElement("sigvelo-leaflet-polyline")], SigveloLeafletPolyline);
72
- //#endregion
73
- export { SigveloLeafletPolyline as t };
@@ -1,35 +0,0 @@
1
- import { t as __decorate } from "./decorate-DcF3lt7P.js";
2
- import { LitElement, css, html } from "lit";
3
- import { customElement, property } from "lit/decorators.js";
4
- //#region src/components/popup/popup.styles.ts
5
- var popup_styles_default = css`
6
- :host {
7
- display: none;
8
- }
9
- `;
10
- //#endregion
11
- //#region src/components/popup/popup.ts
12
- let SigveloLeafletPopup = class SigveloLeafletPopup extends LitElement {
13
- constructor(..._args) {
14
- super(..._args);
15
- this.maxWidth = 300;
16
- this.minWidth = 50;
17
- }
18
- static {
19
- this.styles = [popup_styles_default];
20
- }
21
- render() {
22
- return html` <slot></slot> `;
23
- }
24
- };
25
- __decorate([property({
26
- attribute: "max-width",
27
- type: Number
28
- })], SigveloLeafletPopup.prototype, "maxWidth", void 0);
29
- __decorate([property({
30
- attribute: "min-width",
31
- type: Number
32
- })], SigveloLeafletPopup.prototype, "minWidth", void 0);
33
- SigveloLeafletPopup = __decorate([customElement("sigvelo-leaflet-popup")], SigveloLeafletPopup);
34
- //#endregion
35
- export { SigveloLeafletPopup as t };
@@ -1,64 +0,0 @@
1
- import { n as __toESM, t as require_leaflet_src } from "./leaflet-src-DkjKLRUt.js";
2
- import { t as __decorate } from "./decorate-DcF3lt7P.js";
3
- import { findLeafletMap } from "./components/find-leaflet-map.js";
4
- import { LitElement, css, html } from "lit";
5
- import { customElement, property } from "lit/decorators.js";
6
- //#region src/components/scale-control/scale-control.styles.ts
7
- var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
8
- var scale_control_styles_default = css`
9
- :host {
10
- display: none;
11
- }
12
- `;
13
- //#endregion
14
- //#region src/components/scale-control/scale-control.ts
15
- let SigveloLeafletScaleControl = class SigveloLeafletScaleControl extends LitElement {
16
- constructor(..._args) {
17
- super(..._args);
18
- this.position = "bottomleft";
19
- this.metric = true;
20
- this.imperial = true;
21
- this.maxWidth = 100;
22
- this._control = null;
23
- this._mapEl = null;
24
- }
25
- static {
26
- this.styles = [scale_control_styles_default];
27
- }
28
- async connectedCallback() {
29
- super.connectedCallback();
30
- this._mapEl = findLeafletMap(this);
31
- if (this._mapEl) {
32
- await this._mapEl.mapReady;
33
- this._addControl();
34
- }
35
- }
36
- disconnectedCallback() {
37
- super.disconnectedCallback();
38
- if (this._control && this._mapEl?.map) this._control.remove();
39
- this._control = null;
40
- }
41
- /** @internal */
42
- _addControl() {
43
- if (!this._mapEl?.map) return;
44
- this._control = import_leaflet_src.control.scale({
45
- position: this.position,
46
- metric: this.metric,
47
- imperial: this.imperial,
48
- maxWidth: this.maxWidth
49
- }).addTo(this._mapEl.map);
50
- }
51
- render() {
52
- return html``;
53
- }
54
- };
55
- __decorate([property()], SigveloLeafletScaleControl.prototype, "position", void 0);
56
- __decorate([property({ type: Boolean })], SigveloLeafletScaleControl.prototype, "metric", void 0);
57
- __decorate([property({ type: Boolean })], SigveloLeafletScaleControl.prototype, "imperial", void 0);
58
- __decorate([property({
59
- attribute: "max-width",
60
- type: Number
61
- })], SigveloLeafletScaleControl.prototype, "maxWidth", void 0);
62
- SigveloLeafletScaleControl = __decorate([customElement("sigvelo-leaflet-scale-control")], SigveloLeafletScaleControl);
63
- //#endregion
64
- export { SigveloLeafletScaleControl as t };
@@ -1,83 +0,0 @@
1
- import { n as __toESM, t as require_leaflet_src } from "./leaflet-src-DkjKLRUt.js";
2
- import { t as __decorate } from "./decorate-DcF3lt7P.js";
3
- import { findLeafletMap } from "./components/find-leaflet-map.js";
4
- import { LitElement, css, html } from "lit";
5
- import { customElement, property } from "lit/decorators.js";
6
- //#region src/components/tilelayer/tilelayer.styles.ts
7
- var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
8
- var tilelayer_styles_default = css`
9
- :host {
10
- display: none;
11
- }
12
- `;
13
- //#endregion
14
- //#region src/components/tilelayer/tilelayer.ts
15
- let SigveloLeafletTilelayer = class SigveloLeafletTilelayer extends LitElement {
16
- constructor(..._args) {
17
- super(..._args);
18
- this.url = "";
19
- this.attribution = "";
20
- this.minZoom = 0;
21
- this.maxZoom = 19;
22
- this.subdomains = "abc";
23
- this.opacity = 1;
24
- this._layer = null;
25
- this._mapEl = null;
26
- }
27
- static {
28
- this.styles = [tilelayer_styles_default];
29
- }
30
- async connectedCallback() {
31
- super.connectedCallback();
32
- this._mapEl = findLeafletMap(this);
33
- if (this._mapEl) {
34
- await this._mapEl.mapReady;
35
- this._addLayer();
36
- }
37
- }
38
- disconnectedCallback() {
39
- super.disconnectedCallback();
40
- this._removeLayer();
41
- }
42
- /** @internal */
43
- _addLayer() {
44
- if (!this._mapEl?.map || !this.url) return;
45
- this._layer = import_leaflet_src.tileLayer(this.url, {
46
- attribution: this.attribution,
47
- minZoom: this.minZoom,
48
- maxZoom: this.maxZoom,
49
- subdomains: this.subdomains,
50
- opacity: this.opacity
51
- }).addTo(this._mapEl.map);
52
- }
53
- /** @internal */
54
- _removeLayer() {
55
- this._layer?.remove();
56
- this._layer = null;
57
- }
58
- updated(changed) {
59
- if (changed.has("url") && this._layer) {
60
- this._removeLayer();
61
- this._addLayer();
62
- }
63
- if (changed.has("opacity") && this._layer) this._layer.setOpacity(this.opacity);
64
- }
65
- render() {
66
- return html``;
67
- }
68
- };
69
- __decorate([property()], SigveloLeafletTilelayer.prototype, "url", void 0);
70
- __decorate([property()], SigveloLeafletTilelayer.prototype, "attribution", void 0);
71
- __decorate([property({
72
- attribute: "min-zoom",
73
- type: Number
74
- })], SigveloLeafletTilelayer.prototype, "minZoom", void 0);
75
- __decorate([property({
76
- attribute: "max-zoom",
77
- type: Number
78
- })], SigveloLeafletTilelayer.prototype, "maxZoom", void 0);
79
- __decorate([property()], SigveloLeafletTilelayer.prototype, "subdomains", void 0);
80
- __decorate([property({ type: Number })], SigveloLeafletTilelayer.prototype, "opacity", void 0);
81
- SigveloLeafletTilelayer = __decorate([customElement("sigvelo-leaflet-tilelayer")], SigveloLeafletTilelayer);
82
- //#endregion
83
- export { SigveloLeafletTilelayer as t };