@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,6 +1,6 @@
1
1
  import { t as __decorate } from "../../decorate-DcF3lt7P.js";
2
- import "../../geojson-Dlvc_wAg.js";
3
- import "../../control-DvPCCR2e.js";
2
+ import "../geojson/geojson.js";
3
+ import "../control/control.js";
4
4
  import { css, html, nothing } from "lit";
5
5
  import { customElement, property, state } from "lit/decorators.js";
6
6
  import { createClassifyStyle } from "@mcp-b/geo-support/classification";
@@ -1,2 +1,76 @@
1
- import { t as SigveloLeafletCircle } from "../../circle-BNPIzKH-.js";
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 { LitElement, html } from "lit";
4
+ import { customElement, property } from "lit/decorators.js";
5
+ import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
6
+ import styles from "@mcp-b/geo-support/styles/map-child.styles";
7
+ //#region src/components/circle/circle.ts
8
+ var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
9
+ let SigveloLeafletCircle = class SigveloLeafletCircle extends LitElement {
10
+ constructor(..._args) {
11
+ super(..._args);
12
+ this.latitude = 0;
13
+ this.longitude = 0;
14
+ this.radius = 100;
15
+ this.fillColor = "#3388ff";
16
+ this.fillOpacity = .2;
17
+ this.strokeColor = "#3388ff";
18
+ this.strokeWidth = 3;
19
+ this._circle = null;
20
+ this._mapEl = null;
21
+ }
22
+ static {
23
+ this.styles = [styles];
24
+ }
25
+ async connectedCallback() {
26
+ super.connectedCallback();
27
+ this._mapEl = findMapElement(this, "sigvelo-leaflet-map");
28
+ await this._mapEl?.whenMapReady(this, () => this._addCircle());
29
+ }
30
+ disconnectedCallback() {
31
+ super.disconnectedCallback();
32
+ this._circle?.remove();
33
+ this._circle = null;
34
+ }
35
+ /** @internal */
36
+ _addCircle() {
37
+ if (!this._mapEl?.map) return;
38
+ this._circle = import_leaflet_src.circle([this.latitude, this.longitude], {
39
+ radius: this.radius,
40
+ fillColor: this.fillColor,
41
+ fillOpacity: this.fillOpacity,
42
+ color: this.strokeColor,
43
+ weight: this.strokeWidth
44
+ }).addTo(this._mapEl.map);
45
+ }
46
+ updated(changed) {
47
+ if (!this._circle) return;
48
+ if (changed.has("latitude") || changed.has("longitude")) this._circle.setLatLng([this.latitude, this.longitude]);
49
+ if (changed.has("radius")) this._circle.setRadius(this.radius);
50
+ if (changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth")) this._circle.setStyle({
51
+ fillColor: this.fillColor,
52
+ fillOpacity: this.fillOpacity,
53
+ color: this.strokeColor,
54
+ weight: this.strokeWidth
55
+ });
56
+ }
57
+ render() {
58
+ return html``;
59
+ }
60
+ };
61
+ __decorate([property({ type: Number })], SigveloLeafletCircle.prototype, "latitude", void 0);
62
+ __decorate([property({ type: Number })], SigveloLeafletCircle.prototype, "longitude", void 0);
63
+ __decorate([property({ type: Number })], SigveloLeafletCircle.prototype, "radius", void 0);
64
+ __decorate([property({ attribute: "fill-color" })], SigveloLeafletCircle.prototype, "fillColor", void 0);
65
+ __decorate([property({
66
+ attribute: "fill-opacity",
67
+ type: Number
68
+ })], SigveloLeafletCircle.prototype, "fillOpacity", void 0);
69
+ __decorate([property({ attribute: "stroke-color" })], SigveloLeafletCircle.prototype, "strokeColor", void 0);
70
+ __decorate([property({
71
+ attribute: "stroke-width",
72
+ type: Number
73
+ })], SigveloLeafletCircle.prototype, "strokeWidth", void 0);
74
+ SigveloLeafletCircle = __decorate([customElement("sigvelo-leaflet-circle")], SigveloLeafletCircle);
75
+ //#endregion
2
76
  export { SigveloLeafletCircle };
@@ -1,4 +1,5 @@
1
- import { LitElement } from "lit";
1
+ import { LitElement, PropertyValues } from "lit";
2
+ import { ControlPosition } from "@mcp-b/geo-support/types";
2
3
 
3
4
  //#region src/components/control/control.d.ts
4
5
  /**
@@ -6,6 +7,8 @@ import { LitElement } from "lit";
6
7
  * and places it in one of Leaflet's four control corners, stacking properly
7
8
  * with zoom, attribution, and other controls.
8
9
  *
10
+ * @slot - Control content, retained in the control’s light DOM.
11
+ *
9
12
  * @tag sigvelo-leaflet-control
10
13
  *
11
14
  * @example
@@ -21,7 +24,8 @@ declare class SigveloLeafletControl extends LitElement {
21
24
  /** @internal */
22
25
  static styles: import("lit").CSSResult[];
23
26
  /** Position of the control on the map. */
24
- position: "top-left" | "top-right" | "bottom-left" | "bottom-right";
27
+ position: ControlPosition;
28
+ private _stopPlacement;
25
29
  /** @internal */
26
30
  private _control;
27
31
  /** @internal */
@@ -30,6 +34,8 @@ declare class SigveloLeafletControl extends LitElement {
30
34
  private _toLeafletPosition;
31
35
  connectedCallback(): Promise<void>;
32
36
  disconnectedCallback(): void;
37
+ private _removeControl;
38
+ protected updated(changed: PropertyValues): void;
33
39
  /** @internal */
34
40
  private _addControl;
35
41
  render(): import("lit-html").TemplateResult<1>;
@@ -1,2 +1,73 @@
1
- import { t as SigveloLeafletControl } from "../../control-DvPCCR2e.js";
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 { LitElement, html } from "lit";
4
+ import { customElement, property } from "lit/decorators.js";
5
+ import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
6
+ import { placeControl } from "@mcp-b/geo-support/base/control-placement";
7
+ import styles from "@mcp-b/geo-support/styles/control.styles";
8
+ //#region src/components/control/control.ts
9
+ var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
10
+ let SigveloLeafletControl = class SigveloLeafletControl extends LitElement {
11
+ constructor(..._args) {
12
+ super(..._args);
13
+ this.position = "bottom-left";
14
+ this._stopPlacement = null;
15
+ this._control = null;
16
+ this._mapEl = null;
17
+ }
18
+ static {
19
+ this.styles = [styles];
20
+ }
21
+ /** @internal Map position names to Leaflet format. */
22
+ _toLeafletPosition() {
23
+ return {
24
+ "top-left": "topleft",
25
+ "top-right": "topright",
26
+ "bottom-left": "bottomleft",
27
+ "bottom-right": "bottomright"
28
+ }[this.position] ?? "bottomleft";
29
+ }
30
+ async connectedCallback() {
31
+ super.connectedCallback();
32
+ this._mapEl = findMapElement(this, "sigvelo-leaflet-map");
33
+ await this._mapEl?.whenMapReady(this, () => {
34
+ if (!this._control) this._addControl();
35
+ });
36
+ }
37
+ disconnectedCallback() {
38
+ super.disconnectedCallback();
39
+ this._removeControl();
40
+ }
41
+ _removeControl() {
42
+ this._stopPlacement?.();
43
+ this._stopPlacement = null;
44
+ this._control?.remove();
45
+ this._control = null;
46
+ }
47
+ updated(changed) {
48
+ if (changed.has("position") && this._control) {
49
+ this._removeControl();
50
+ this._addControl();
51
+ }
52
+ }
53
+ /** @internal */
54
+ _addControl() {
55
+ if (!this._mapEl?.map) return;
56
+ const CustomControl = import_leaflet_src.Control.extend({ onAdd: () => {
57
+ const container = import_leaflet_src.DomUtil.create("div", "sigvelo-leaflet-custom-control");
58
+ import_leaflet_src.DomEvent.disableClickPropagation(container);
59
+ import_leaflet_src.DomEvent.disableScrollPropagation(container);
60
+ return container;
61
+ } });
62
+ this._control = new CustomControl({ position: this._toLeafletPosition() });
63
+ this._control.addTo(this._mapEl.map);
64
+ this._stopPlacement = placeControl(this, this._control.getContainer(), this._mapEl);
65
+ }
66
+ render() {
67
+ return html` <slot></slot> `;
68
+ }
69
+ };
70
+ __decorate([property()], SigveloLeafletControl.prototype, "position", void 0);
71
+ SigveloLeafletControl = __decorate([customElement("sigvelo-leaflet-control")], SigveloLeafletControl);
72
+ //#endregion
2
73
  export { SigveloLeafletControl };
@@ -1,2 +1,180 @@
1
- import { t as SigveloLeafletGeojson } from "../../geojson-Dlvc_wAg.js";
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 { LitElement, html } from "lit";
5
+ import { customElement, property } from "lit/decorators.js";
6
+ import { SigveloFeatureClickEvent } from "@mcp-b/geo-support/events";
7
+ import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
8
+ import styles from "@mcp-b/geo-support/styles/map-child.styles";
9
+ import { subscribeClassify } from "@mcp-b/geo-support/classification";
10
+ //#region src/components/geojson/geojson.ts
11
+ var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
12
+ function formatPopupProperty(value) {
13
+ if (typeof value === "string") return value;
14
+ if (typeof value === "number") return Number.isFinite(value) ? value.toLocaleString(void 0, { maximumSignificantDigits: 4 }) : void 0;
15
+ if (typeof value === "boolean") return value ? "Yes" : "No";
16
+ }
17
+ let SigveloLeafletGeojson = class SigveloLeafletGeojson extends LitElement {
18
+ constructor(..._args) {
19
+ super(..._args);
20
+ this.data = null;
21
+ this.styleFunction = null;
22
+ this.fillColor = "#3388ff";
23
+ this.fillOpacity = .2;
24
+ this.strokeColor = "#3388ff";
25
+ this.strokeWidth = 3;
26
+ this.strokeOpacity = 1;
27
+ this.interactive = true;
28
+ this.popupTitleProperty = "";
29
+ this.popupValueProperty = "";
30
+ this.popupValueLabel = "";
31
+ this.fitBounds = false;
32
+ this.channel = "";
33
+ this._layer = null;
34
+ this._mapEl = null;
35
+ this._unsubscribeChannel = null;
36
+ }
37
+ static {
38
+ this.styles = [styles];
39
+ }
40
+ /** Access the underlying Leaflet GeoJSON layer. */
41
+ get layer() {
42
+ return this._layer;
43
+ }
44
+ async connectedCallback() {
45
+ super.connectedCallback();
46
+ this._subscribeChannel();
47
+ this._mapEl = findMapElement(this, "sigvelo-leaflet-map");
48
+ await this._mapEl?.whenMapReady(this, () => this._addLayer());
49
+ }
50
+ disconnectedCallback() {
51
+ super.disconnectedCallback();
52
+ this._unsubscribeChannel?.();
53
+ this._unsubscribeChannel = null;
54
+ this._removeLayer();
55
+ }
56
+ /** @internal */
57
+ _subscribeChannel() {
58
+ this._unsubscribeChannel?.();
59
+ if (!this.channel) return;
60
+ this._unsubscribeChannel = subscribeClassify(this.channel, (detail) => {
61
+ this.styleFunction = detail.styleFunction;
62
+ });
63
+ }
64
+ /** @internal */
65
+ _toGeoJsonFeature(feature) {
66
+ return {
67
+ type: "Feature",
68
+ geometry: feature.geometry,
69
+ properties: feature.properties ?? null,
70
+ id: feature.id
71
+ };
72
+ }
73
+ /** @internal */
74
+ _getStyleForFeature(feature) {
75
+ if (this.styleFunction) {
76
+ const s = this.styleFunction(this._toGeoJsonFeature(feature));
77
+ if (s) return {
78
+ fillColor: s.fillColor ?? this.fillColor,
79
+ fillOpacity: s.fillOpacity ?? this.fillOpacity,
80
+ color: s.strokeColor ?? this.strokeColor,
81
+ weight: s.strokeWidth ?? this.strokeWidth,
82
+ opacity: s.strokeOpacity ?? this.strokeOpacity
83
+ };
84
+ }
85
+ return {
86
+ fillColor: this.fillColor,
87
+ fillOpacity: this.fillOpacity,
88
+ color: this.strokeColor,
89
+ weight: this.strokeWidth,
90
+ opacity: this.strokeOpacity
91
+ };
92
+ }
93
+ /** @internal */
94
+ _getPopupForFeature(feature) {
95
+ if (!this.popupTitleProperty) return;
96
+ const properties = feature.properties ?? {};
97
+ const title = formatPopupProperty(properties[this.popupTitleProperty]);
98
+ if (title === void 0) return;
99
+ const content = document.createElement("div");
100
+ const heading = document.createElement("strong");
101
+ heading.textContent = title;
102
+ content.appendChild(heading);
103
+ if (this.popupValueProperty) {
104
+ const value = formatPopupProperty(properties[this.popupValueProperty]);
105
+ if (value !== void 0) {
106
+ const detail = document.createElement("div");
107
+ detail.textContent = this.popupValueLabel ? `${this.popupValueLabel}: ${value}` : value;
108
+ content.appendChild(detail);
109
+ }
110
+ }
111
+ return content;
112
+ }
113
+ /** @internal */
114
+ _addLayer() {
115
+ this._removeLayer();
116
+ if (!this._mapEl?.map || !this.data) return;
117
+ this._layer = import_leaflet_src.geoJSON(this.data, {
118
+ style: (feature) => feature ? this._getStyleForFeature(feature) : {},
119
+ interactive: this.interactive,
120
+ onEachFeature: (feature, layer) => {
121
+ const popup = this._getPopupForFeature(feature);
122
+ if (popup) layer.bindPopup(popup);
123
+ if (this.interactive) layer.on("click", (e) => {
124
+ this.dispatchEvent(new SigveloFeatureClickEvent(this._toGeoJsonFeature(feature), {
125
+ lat: e.latlng.lat,
126
+ lng: e.latlng.lng
127
+ }));
128
+ });
129
+ }
130
+ }).addTo(this._mapEl.map);
131
+ if (this.fitBounds && this._layer.getLayers().length > 0) {
132
+ const bounds = this._layer.getBounds();
133
+ if (bounds.isValid()) this._mapEl.map.fitBounds(bounds, { padding: [12, 12] });
134
+ }
135
+ }
136
+ /** @internal */
137
+ _removeLayer() {
138
+ this._layer?.remove();
139
+ this._layer = null;
140
+ }
141
+ updated(changed) {
142
+ if (changed.has("data") || changed.has("interactive") || changed.has("popupTitleProperty") || changed.has("popupValueProperty") || changed.has("popupValueLabel")) this._addLayer();
143
+ 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) : {});
144
+ else if (changed.has("fitBounds") && this.fitBounds && this._layer && this._mapEl?.map) {
145
+ const bounds = this._layer.getBounds();
146
+ if (bounds.isValid()) this._mapEl.map.fitBounds(bounds, { padding: [12, 12] });
147
+ }
148
+ }
149
+ render() {
150
+ return html``;
151
+ }
152
+ };
153
+ __decorate([property({ attribute: false })], SigveloLeafletGeojson.prototype, "data", void 0);
154
+ __decorate([property({ attribute: false })], SigveloLeafletGeojson.prototype, "styleFunction", void 0);
155
+ __decorate([property({ attribute: "fill-color" })], SigveloLeafletGeojson.prototype, "fillColor", void 0);
156
+ __decorate([property({
157
+ attribute: "fill-opacity",
158
+ type: Number
159
+ })], SigveloLeafletGeojson.prototype, "fillOpacity", void 0);
160
+ __decorate([property({ attribute: "stroke-color" })], SigveloLeafletGeojson.prototype, "strokeColor", void 0);
161
+ __decorate([property({
162
+ attribute: "stroke-width",
163
+ type: Number
164
+ })], SigveloLeafletGeojson.prototype, "strokeWidth", void 0);
165
+ __decorate([property({
166
+ attribute: "stroke-opacity",
167
+ type: Number
168
+ })], SigveloLeafletGeojson.prototype, "strokeOpacity", void 0);
169
+ __decorate([property({ type: Boolean })], SigveloLeafletGeojson.prototype, "interactive", void 0);
170
+ __decorate([property({ attribute: "popup-title-property" })], SigveloLeafletGeojson.prototype, "popupTitleProperty", void 0);
171
+ __decorate([property({ attribute: "popup-value-property" })], SigveloLeafletGeojson.prototype, "popupValueProperty", void 0);
172
+ __decorate([property({ attribute: "popup-value-label" })], SigveloLeafletGeojson.prototype, "popupValueLabel", void 0);
173
+ __decorate([property({
174
+ attribute: "fit-bounds",
175
+ type: Boolean
176
+ })], SigveloLeafletGeojson.prototype, "fitBounds", void 0);
177
+ __decorate([property()], SigveloLeafletGeojson.prototype, "channel", void 0);
178
+ SigveloLeafletGeojson = __decorate([customElement("sigvelo-leaflet-geojson")], SigveloLeafletGeojson);
179
+ //#endregion
2
180
  export { SigveloLeafletGeojson };
@@ -1,2 +1,2 @@
1
- import { t as SigveloLeafletMap } from "../../map-DGu4FVda.js";
1
+ import { t as SigveloLeafletMap } from "../../map-ChMH_5_A.js";
2
2
  export { SigveloLeafletMap };
@@ -1,2 +1,103 @@
1
- import { t as SigveloLeafletMarker } from "../../marker-RT0-gpae.js";
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 { LitElement, html } from "lit";
5
+ import { customElement, property } from "lit/decorators.js";
6
+ import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
7
+ import styles from "@mcp-b/geo-support/styles/map-child.styles";
8
+ import { clonePopupContent } from "@mcp-b/geo-support/base/popup-content";
9
+ //#region src/components/marker/marker.ts
10
+ var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
11
+ let SigveloLeafletMarker = class SigveloLeafletMarker extends LitElement {
12
+ constructor(..._args) {
13
+ super(..._args);
14
+ this.latitude = 0;
15
+ this.longitude = 0;
16
+ this.title = "";
17
+ this.draggable = false;
18
+ this.opacity = 1;
19
+ this.iconUrl = "";
20
+ this.iconWidth = 25;
21
+ this.iconHeight = 41;
22
+ this._marker = null;
23
+ this._mapEl = null;
24
+ }
25
+ static {
26
+ this.styles = [styles];
27
+ }
28
+ /** Access the underlying Leaflet marker instance. */
29
+ get marker() {
30
+ return this._marker;
31
+ }
32
+ async connectedCallback() {
33
+ super.connectedCallback();
34
+ this._mapEl = findMapElement(this, "sigvelo-leaflet-map");
35
+ await this._mapEl?.whenMapReady(this, () => this._addMarker());
36
+ }
37
+ disconnectedCallback() {
38
+ super.disconnectedCallback();
39
+ this._removeMarker();
40
+ }
41
+ /** @internal */
42
+ _addMarker() {
43
+ this._removeMarker();
44
+ if (!this._mapEl?.map) return;
45
+ const options = {
46
+ title: this.title,
47
+ draggable: this.draggable,
48
+ opacity: this.opacity
49
+ };
50
+ if (this.iconUrl) options.icon = import_leaflet_src.icon({
51
+ iconUrl: this.iconUrl,
52
+ iconSize: [this.iconWidth, this.iconHeight],
53
+ iconAnchor: [this.iconWidth / 2, this.iconHeight],
54
+ popupAnchor: [0, -this.iconHeight]
55
+ });
56
+ this._marker = import_leaflet_src.marker([this.latitude, this.longitude], options).addTo(this._mapEl.map);
57
+ this._bindChildPopup();
58
+ this._marker.on("dragend", () => {
59
+ if (!this._marker) return;
60
+ const pos = this._marker.getLatLng();
61
+ this.latitude = pos.lat;
62
+ this.longitude = pos.lng;
63
+ });
64
+ }
65
+ /** @internal */
66
+ _removeMarker() {
67
+ this._marker?.remove();
68
+ this._marker = null;
69
+ }
70
+ /** @internal */
71
+ _bindChildPopup() {
72
+ if (!this._marker) return;
73
+ const popupEl = this.querySelector("sigvelo-leaflet-popup");
74
+ if (popupEl) this._marker.bindPopup(clonePopupContent(popupEl));
75
+ }
76
+ updated() {
77
+ if (this._marker) {
78
+ this._marker.setLatLng([this.latitude, this.longitude]);
79
+ this._marker.setOpacity(this.opacity);
80
+ this._bindChildPopup();
81
+ }
82
+ }
83
+ render() {
84
+ return html` <slot></slot> `;
85
+ }
86
+ };
87
+ __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "latitude", void 0);
88
+ __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "longitude", void 0);
89
+ __decorate([property()], SigveloLeafletMarker.prototype, "title", void 0);
90
+ __decorate([property({ type: Boolean })], SigveloLeafletMarker.prototype, "draggable", void 0);
91
+ __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "opacity", void 0);
92
+ __decorate([property({ attribute: "icon-url" })], SigveloLeafletMarker.prototype, "iconUrl", void 0);
93
+ __decorate([property({
94
+ attribute: "icon-width",
95
+ type: Number
96
+ })], SigveloLeafletMarker.prototype, "iconWidth", void 0);
97
+ __decorate([property({
98
+ attribute: "icon-height",
99
+ type: Number
100
+ })], SigveloLeafletMarker.prototype, "iconHeight", void 0);
101
+ SigveloLeafletMarker = __decorate([customElement("sigvelo-leaflet-marker")], SigveloLeafletMarker);
102
+ //#endregion
2
103
  export { SigveloLeafletMarker };
@@ -1,2 +1,70 @@
1
- import { t as SigveloLeafletPolygon } from "../../polygon-DtiZDmnC.js";
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 { LitElement, html } from "lit";
4
+ import { customElement, property } from "lit/decorators.js";
5
+ import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
6
+ import styles from "@mcp-b/geo-support/styles/map-child.styles";
7
+ //#region src/components/polygon/polygon.ts
8
+ var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
9
+ let SigveloLeafletPolygon = class SigveloLeafletPolygon extends LitElement {
10
+ constructor(..._args) {
11
+ super(..._args);
12
+ this.positions = [];
13
+ this.fillColor = "#3388ff";
14
+ this.fillOpacity = .2;
15
+ this.strokeColor = "#3388ff";
16
+ this.strokeWidth = 3;
17
+ this._polygon = null;
18
+ this._mapEl = null;
19
+ }
20
+ static {
21
+ this.styles = [styles];
22
+ }
23
+ async connectedCallback() {
24
+ super.connectedCallback();
25
+ this._mapEl = findMapElement(this, "sigvelo-leaflet-map");
26
+ await this._mapEl?.whenMapReady(this, () => this._addPolygon());
27
+ }
28
+ disconnectedCallback() {
29
+ super.disconnectedCallback();
30
+ this._polygon?.remove();
31
+ this._polygon = null;
32
+ }
33
+ /** @internal */
34
+ _addPolygon() {
35
+ if (!this._mapEl?.map) return;
36
+ this._polygon = import_leaflet_src.polygon(this.positions, {
37
+ fillColor: this.fillColor,
38
+ fillOpacity: this.fillOpacity,
39
+ color: this.strokeColor,
40
+ weight: this.strokeWidth
41
+ }).addTo(this._mapEl.map);
42
+ }
43
+ updated(changed) {
44
+ if (!this._polygon) return;
45
+ if (changed.has("positions")) this._polygon.setLatLngs(this.positions);
46
+ if (changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth")) this._polygon.setStyle({
47
+ fillColor: this.fillColor,
48
+ fillOpacity: this.fillOpacity,
49
+ color: this.strokeColor,
50
+ weight: this.strokeWidth
51
+ });
52
+ }
53
+ render() {
54
+ return html``;
55
+ }
56
+ };
57
+ __decorate([property({ attribute: false })], SigveloLeafletPolygon.prototype, "positions", void 0);
58
+ __decorate([property({ attribute: "fill-color" })], SigveloLeafletPolygon.prototype, "fillColor", void 0);
59
+ __decorate([property({
60
+ attribute: "fill-opacity",
61
+ type: Number
62
+ })], SigveloLeafletPolygon.prototype, "fillOpacity", void 0);
63
+ __decorate([property({ attribute: "stroke-color" })], SigveloLeafletPolygon.prototype, "strokeColor", void 0);
64
+ __decorate([property({
65
+ attribute: "stroke-width",
66
+ type: Number
67
+ })], SigveloLeafletPolygon.prototype, "strokeWidth", void 0);
68
+ SigveloLeafletPolygon = __decorate([customElement("sigvelo-leaflet-polygon")], SigveloLeafletPolygon);
69
+ //#endregion
2
70
  export { SigveloLeafletPolygon };
@@ -1,2 +1,64 @@
1
- import { t as SigveloLeafletPolyline } from "../../polyline-C3VgapkC.js";
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 { LitElement, html } from "lit";
4
+ import { customElement, property } from "lit/decorators.js";
5
+ import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
6
+ import styles from "@mcp-b/geo-support/styles/map-child.styles";
7
+ //#region src/components/polyline/polyline.ts
8
+ var import_leaflet_src = /* @__PURE__ */ __toESM(require_leaflet_src(), 1);
9
+ let SigveloLeafletPolyline = class SigveloLeafletPolyline extends LitElement {
10
+ constructor(..._args) {
11
+ super(..._args);
12
+ this.positions = [];
13
+ this.color = "#3388ff";
14
+ this.weight = 3;
15
+ this.opacity = 1;
16
+ this.dashArray = "";
17
+ this._polyline = null;
18
+ this._mapEl = null;
19
+ }
20
+ static {
21
+ this.styles = [styles];
22
+ }
23
+ async connectedCallback() {
24
+ super.connectedCallback();
25
+ this._mapEl = findMapElement(this, "sigvelo-leaflet-map");
26
+ await this._mapEl?.whenMapReady(this, () => this._addPolyline());
27
+ }
28
+ disconnectedCallback() {
29
+ super.disconnectedCallback();
30
+ this._polyline?.remove();
31
+ this._polyline = null;
32
+ }
33
+ /** @internal */
34
+ _addPolyline() {
35
+ if (!this._mapEl?.map) return;
36
+ this._polyline = import_leaflet_src.polyline(this.positions, {
37
+ color: this.color,
38
+ weight: this.weight,
39
+ opacity: this.opacity,
40
+ dashArray: this.dashArray || void 0
41
+ }).addTo(this._mapEl.map);
42
+ }
43
+ updated(changed) {
44
+ if (!this._polyline) return;
45
+ if (changed.has("positions")) this._polyline.setLatLngs(this.positions);
46
+ if (changed.has("color") || changed.has("weight") || changed.has("opacity") || changed.has("dashArray")) this._polyline.setStyle({
47
+ color: this.color,
48
+ weight: this.weight,
49
+ opacity: this.opacity,
50
+ dashArray: this.dashArray || void 0
51
+ });
52
+ }
53
+ render() {
54
+ return html``;
55
+ }
56
+ };
57
+ __decorate([property({ attribute: false })], SigveloLeafletPolyline.prototype, "positions", void 0);
58
+ __decorate([property()], SigveloLeafletPolyline.prototype, "color", void 0);
59
+ __decorate([property({ type: Number })], SigveloLeafletPolyline.prototype, "weight", void 0);
60
+ __decorate([property({ type: Number })], SigveloLeafletPolyline.prototype, "opacity", void 0);
61
+ __decorate([property({ attribute: "dash-array" })], SigveloLeafletPolyline.prototype, "dashArray", void 0);
62
+ SigveloLeafletPolyline = __decorate([customElement("sigvelo-leaflet-polyline")], SigveloLeafletPolyline);
63
+ //#endregion
2
64
  export { SigveloLeafletPolyline };
@@ -1,2 +1,29 @@
1
- import { t as SigveloLeafletPopup } from "../../popup-BDNUUZWQ.js";
1
+ import { t as __decorate } from "../../decorate-DcF3lt7P.js";
2
+ import { LitElement, html } from "lit";
3
+ import { customElement, property } from "lit/decorators.js";
4
+ import styles from "@mcp-b/geo-support/styles/map-child.styles";
5
+ //#region src/components/popup/popup.ts
6
+ let SigveloLeafletPopup = class SigveloLeafletPopup extends LitElement {
7
+ constructor(..._args) {
8
+ super(..._args);
9
+ this.maxWidth = 300;
10
+ this.minWidth = 50;
11
+ }
12
+ static {
13
+ this.styles = [styles];
14
+ }
15
+ render() {
16
+ return html` <slot></slot> `;
17
+ }
18
+ };
19
+ __decorate([property({
20
+ attribute: "max-width",
21
+ type: Number
22
+ })], SigveloLeafletPopup.prototype, "maxWidth", void 0);
23
+ __decorate([property({
24
+ attribute: "min-width",
25
+ type: Number
26
+ })], SigveloLeafletPopup.prototype, "minWidth", void 0);
27
+ SigveloLeafletPopup = __decorate([customElement("sigvelo-leaflet-popup")], SigveloLeafletPopup);
28
+ //#endregion
2
29
  export { SigveloLeafletPopup };