@mcp-b/geo-leaflet 0.2.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/dist/circle-CqXHsyYH.js +84 -0
  3. package/dist/components/choropleth/choropleth.d.ts +68 -0
  4. package/dist/components/choropleth/choropleth.js +195 -0
  5. package/dist/components/circle/circle.d.ts +43 -0
  6. package/dist/components/circle/circle.js +2 -0
  7. package/dist/components/control/control.d.ts +43 -0
  8. package/dist/components/control/control.js +2 -0
  9. package/dist/components/find-leaflet-map.d.ts +11 -0
  10. package/dist/components/find-leaflet-map.js +17 -0
  11. package/dist/components/geojson/geojson.d.ts +80 -0
  12. package/dist/components/geojson/geojson.js +2 -0
  13. package/dist/components/map/map.d.ts +44 -0
  14. package/dist/components/map/map.js +2 -0
  15. package/dist/components/marker/marker.d.ts +53 -0
  16. package/dist/components/marker/marker.js +2 -0
  17. package/dist/components/polygon/polygon.d.ts +39 -0
  18. package/dist/components/polygon/polygon.js +2 -0
  19. package/dist/components/polyline/polyline.d.ts +39 -0
  20. package/dist/components/polyline/polyline.js +2 -0
  21. package/dist/components/popup/popup.d.ts +30 -0
  22. package/dist/components/popup/popup.js +2 -0
  23. package/dist/components/scale-control/scale-control.d.ts +37 -0
  24. package/dist/components/scale-control/scale-control.js +2 -0
  25. package/dist/components/tilelayer/tilelayer.d.ts +43 -0
  26. package/dist/components/tilelayer/tilelayer.js +2 -0
  27. package/dist/control-ysNMOWeF.js +67 -0
  28. package/dist/decorate-DcF3lt7P.js +9 -0
  29. package/dist/default-icon-BVVgDSdq.d.ts +1 -0
  30. package/dist/default-icon.d.ts +1 -0
  31. package/dist/default-icon.js +12 -0
  32. package/dist/docs/custom-elements.json +2051 -0
  33. package/dist/geojson-DPaCrjMF.js +189 -0
  34. package/dist/index.d.ts +12 -0
  35. package/dist/index.js +12 -0
  36. package/dist/map-DRJUOrtM.js +204 -0
  37. package/dist/marker-D4gW4fyF.js +115 -0
  38. package/dist/polygon-DbFiHm4R.js +78 -0
  39. package/dist/polyline-SAcEwHDC.js +72 -0
  40. package/dist/popup-BDNUUZWQ.js +35 -0
  41. package/dist/scale-control-BR_iH4gM.js +63 -0
  42. package/dist/tilelayer-DI2cPv01.js +82 -0
  43. package/package.json +75 -0
@@ -0,0 +1,189 @@
1
+ import "./default-icon.js";
2
+ import { t as __decorate } from "./decorate-DcF3lt7P.js";
3
+ import { findLeafletMap } from "./components/find-leaflet-map.js";
4
+ import * as L from "leaflet";
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 geojson_styles_default = css`
11
+ :host {
12
+ display: none;
13
+ }
14
+ `;
15
+ //#endregion
16
+ //#region src/components/geojson/geojson.ts
17
+ function formatPopupProperty(value) {
18
+ if (typeof value === "string") return value;
19
+ if (typeof value === "number") return Number.isFinite(value) ? value.toLocaleString(void 0, { maximumSignificantDigits: 4 }) : void 0;
20
+ if (typeof value === "boolean") return value ? "Yes" : "No";
21
+ }
22
+ let SigveloLeafletGeojson = class SigveloLeafletGeojson extends LitElement {
23
+ constructor(..._args) {
24
+ super(..._args);
25
+ this.data = null;
26
+ this.styleFunction = null;
27
+ this.fillColor = "#3388ff";
28
+ this.fillOpacity = .2;
29
+ this.strokeColor = "#3388ff";
30
+ this.strokeWidth = 3;
31
+ this.strokeOpacity = 1;
32
+ this.interactive = true;
33
+ this.popupTitleProperty = "";
34
+ this.popupValueProperty = "";
35
+ this.popupValueLabel = "";
36
+ this.fitBounds = false;
37
+ this.channel = "";
38
+ this._layer = null;
39
+ this._mapEl = null;
40
+ this._unsubscribeChannel = null;
41
+ }
42
+ static {
43
+ this.styles = [geojson_styles_default];
44
+ }
45
+ /** Access the underlying Leaflet GeoJSON layer. */
46
+ get layer() {
47
+ return this._layer;
48
+ }
49
+ async connectedCallback() {
50
+ super.connectedCallback();
51
+ this._subscribeChannel();
52
+ this._mapEl = findLeafletMap(this);
53
+ if (this._mapEl) {
54
+ await this._mapEl.mapReady;
55
+ if (!this.isConnected) return;
56
+ this._addLayer();
57
+ }
58
+ }
59
+ disconnectedCallback() {
60
+ super.disconnectedCallback();
61
+ this._unsubscribeChannel?.();
62
+ this._unsubscribeChannel = null;
63
+ this._removeLayer();
64
+ }
65
+ /** @internal */
66
+ _subscribeChannel() {
67
+ this._unsubscribeChannel?.();
68
+ if (!this.channel) return;
69
+ this._unsubscribeChannel = subscribeClassify(this.channel, (detail) => {
70
+ this.styleFunction = detail.styleFunction;
71
+ });
72
+ }
73
+ /** @internal */
74
+ _toGeoJsonFeature(feature) {
75
+ return {
76
+ type: "Feature",
77
+ geometry: feature.geometry,
78
+ properties: feature.properties ?? null,
79
+ id: feature.id
80
+ };
81
+ }
82
+ /** @internal */
83
+ _getStyleForFeature(feature) {
84
+ if (this.styleFunction) {
85
+ const s = this.styleFunction(this._toGeoJsonFeature(feature));
86
+ if (s) return {
87
+ fillColor: s.fillColor ?? this.fillColor,
88
+ fillOpacity: s.fillOpacity ?? this.fillOpacity,
89
+ color: s.strokeColor ?? this.strokeColor,
90
+ weight: s.strokeWidth ?? this.strokeWidth,
91
+ opacity: s.strokeOpacity ?? this.strokeOpacity
92
+ };
93
+ }
94
+ return {
95
+ fillColor: this.fillColor,
96
+ fillOpacity: this.fillOpacity,
97
+ color: this.strokeColor,
98
+ weight: this.strokeWidth,
99
+ opacity: this.strokeOpacity
100
+ };
101
+ }
102
+ /** @internal */
103
+ _getPopupForFeature(feature) {
104
+ if (!this.popupTitleProperty) return;
105
+ const properties = feature.properties ?? {};
106
+ const title = formatPopupProperty(properties[this.popupTitleProperty]);
107
+ if (title === void 0) return;
108
+ const content = document.createElement("div");
109
+ const heading = document.createElement("strong");
110
+ heading.textContent = title;
111
+ content.appendChild(heading);
112
+ if (this.popupValueProperty) {
113
+ const value = formatPopupProperty(properties[this.popupValueProperty]);
114
+ if (value !== void 0) {
115
+ const detail = document.createElement("div");
116
+ detail.textContent = this.popupValueLabel ? `${this.popupValueLabel}: ${value}` : value;
117
+ content.appendChild(detail);
118
+ }
119
+ }
120
+ return content;
121
+ }
122
+ /** @internal */
123
+ _addLayer() {
124
+ this._removeLayer();
125
+ if (!this._mapEl?.map || !this.data) return;
126
+ this._layer = L.geoJSON(this.data, {
127
+ style: (feature) => feature ? this._getStyleForFeature(feature) : {},
128
+ interactive: this.interactive,
129
+ onEachFeature: (feature, layer) => {
130
+ const popup = this._getPopupForFeature(feature);
131
+ if (popup) layer.bindPopup(popup);
132
+ if (this.interactive) layer.on("click", (e) => {
133
+ this.dispatchEvent(new SigveloFeatureClickEvent(this._toGeoJsonFeature(feature), {
134
+ lat: e.latlng.lat,
135
+ lng: e.latlng.lng
136
+ }));
137
+ });
138
+ }
139
+ }).addTo(this._mapEl.map);
140
+ if (this.fitBounds && this._layer.getLayers().length > 0) {
141
+ const bounds = this._layer.getBounds();
142
+ if (bounds.isValid()) this._mapEl.map.fitBounds(bounds, { padding: [12, 12] });
143
+ }
144
+ }
145
+ /** @internal */
146
+ _removeLayer() {
147
+ this._layer?.remove();
148
+ this._layer = null;
149
+ }
150
+ updated(changed) {
151
+ if (changed.has("data") || changed.has("interactive") || changed.has("popupTitleProperty") || changed.has("popupValueProperty") || changed.has("popupValueLabel")) this._addLayer();
152
+ 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) : {});
153
+ else if (changed.has("fitBounds") && this.fitBounds && this._layer && this._mapEl?.map) {
154
+ const bounds = this._layer.getBounds();
155
+ if (bounds.isValid()) this._mapEl.map.fitBounds(bounds, { padding: [12, 12] });
156
+ }
157
+ }
158
+ render() {
159
+ return html``;
160
+ }
161
+ };
162
+ __decorate([property({ attribute: false })], SigveloLeafletGeojson.prototype, "data", void 0);
163
+ __decorate([property({ attribute: false })], SigveloLeafletGeojson.prototype, "styleFunction", void 0);
164
+ __decorate([property({ attribute: "fill-color" })], SigveloLeafletGeojson.prototype, "fillColor", void 0);
165
+ __decorate([property({
166
+ attribute: "fill-opacity",
167
+ type: Number
168
+ })], SigveloLeafletGeojson.prototype, "fillOpacity", void 0);
169
+ __decorate([property({ attribute: "stroke-color" })], SigveloLeafletGeojson.prototype, "strokeColor", void 0);
170
+ __decorate([property({
171
+ attribute: "stroke-width",
172
+ type: Number
173
+ })], SigveloLeafletGeojson.prototype, "strokeWidth", void 0);
174
+ __decorate([property({
175
+ attribute: "stroke-opacity",
176
+ type: Number
177
+ })], SigveloLeafletGeojson.prototype, "strokeOpacity", void 0);
178
+ __decorate([property({ type: Boolean })], SigveloLeafletGeojson.prototype, "interactive", void 0);
179
+ __decorate([property({ attribute: "popup-title-property" })], SigveloLeafletGeojson.prototype, "popupTitleProperty", void 0);
180
+ __decorate([property({ attribute: "popup-value-property" })], SigveloLeafletGeojson.prototype, "popupValueProperty", void 0);
181
+ __decorate([property({ attribute: "popup-value-label" })], SigveloLeafletGeojson.prototype, "popupValueLabel", void 0);
182
+ __decorate([property({
183
+ attribute: "fit-bounds",
184
+ type: Boolean
185
+ })], SigveloLeafletGeojson.prototype, "fitBounds", void 0);
186
+ __decorate([property()], SigveloLeafletGeojson.prototype, "channel", void 0);
187
+ SigveloLeafletGeojson = __decorate([customElement("sigvelo-leaflet-geojson")], SigveloLeafletGeojson);
188
+ //#endregion
189
+ export { SigveloLeafletGeojson as t };
@@ -0,0 +1,12 @@
1
+ import { SigveloLeafletControl } from "./components/control/control.js";
2
+ import { SigveloLeafletGeojson } from "./components/geojson/geojson.js";
3
+ import { SigveloLeafletChoropleth } from "./components/choropleth/choropleth.js";
4
+ import { SigveloLeafletCircle } from "./components/circle/circle.js";
5
+ import { SigveloLeafletMap } from "./components/map/map.js";
6
+ import { SigveloLeafletMarker } from "./components/marker/marker.js";
7
+ import { SigveloLeafletPolygon } from "./components/polygon/polygon.js";
8
+ import { SigveloLeafletPolyline } from "./components/polyline/polyline.js";
9
+ import { SigveloLeafletPopup } from "./components/popup/popup.js";
10
+ import { SigveloLeafletScaleControl } from "./components/scale-control/scale-control.js";
11
+ import { SigveloLeafletTilelayer } from "./components/tilelayer/tilelayer.js";
12
+ export { SigveloLeafletChoropleth, SigveloLeafletCircle, SigveloLeafletControl, SigveloLeafletGeojson, SigveloLeafletMap, SigveloLeafletMarker, SigveloLeafletPolygon, SigveloLeafletPolyline, SigveloLeafletPopup, SigveloLeafletScaleControl, SigveloLeafletTilelayer };
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { t as SigveloLeafletMap } from "./map-DRJUOrtM.js";
2
+ import { t as SigveloLeafletTilelayer } from "./tilelayer-DI2cPv01.js";
3
+ import { t as SigveloLeafletMarker } from "./marker-D4gW4fyF.js";
4
+ import { t as SigveloLeafletPopup } from "./popup-BDNUUZWQ.js";
5
+ import { t as SigveloLeafletGeojson } from "./geojson-DPaCrjMF.js";
6
+ import { t as SigveloLeafletControl } from "./control-ysNMOWeF.js";
7
+ import { SigveloLeafletChoropleth } from "./components/choropleth/choropleth.js";
8
+ import { t as SigveloLeafletCircle } from "./circle-CqXHsyYH.js";
9
+ import { t as SigveloLeafletPolyline } from "./polyline-SAcEwHDC.js";
10
+ import { t as SigveloLeafletPolygon } from "./polygon-DbFiHm4R.js";
11
+ import { t as SigveloLeafletScaleControl } from "./scale-control-BR_iH4gM.js";
12
+ export { SigveloLeafletChoropleth, SigveloLeafletCircle, SigveloLeafletControl, SigveloLeafletGeojson, SigveloLeafletMap, SigveloLeafletMarker, SigveloLeafletPolygon, SigveloLeafletPolyline, SigveloLeafletPopup, SigveloLeafletScaleControl, SigveloLeafletTilelayer };
@@ -0,0 +1,204 @@
1
+ import { t as __decorate } from "./decorate-DcF3lt7P.js";
2
+ import * as L from "leaflet";
3
+ import iconUrl from "leaflet/dist/images/marker-icon.png";
4
+ import { css, unsafeCSS } from "lit";
5
+ import { customElement, property } from "lit/decorators.js";
6
+ import { GeoMapElement } from "@mcp-b/geo-support/base/geo-map-element";
7
+ import { SigveloMapClickEvent, SigveloMapLoadEvent, SigveloMapMoveEndEvent, SigveloMapMoveEvent, SigveloMapZoomEndEvent, SigveloMapZoomEvent } from "@mcp-b/geo-support/events";
8
+ import leafletCss from "leaflet/dist/leaflet.css?raw";
9
+ import layersIconUrl from "leaflet/dist/images/layers.png";
10
+ import layersIcon2xUrl from "leaflet/dist/images/layers-2x.png";
11
+ //#region src/components/map/map.styles.ts
12
+ var map_styles_default = css`
13
+ :host {
14
+ display: block;
15
+ position: relative;
16
+ box-sizing: border-box;
17
+ min-height: 300px;
18
+ overflow: hidden;
19
+ border: 1px solid var(--sigvelo-color-neutral-border-muted, rgb(255 255 255 / 15%));
20
+ border-radius: var(--sigvelo-radius-md, 8px);
21
+ background: var(--sigvelo-color-surface-sunken, #171717);
22
+ }
23
+
24
+ .leaflet-container {
25
+ border-radius: inherit;
26
+ background: var(--sigvelo-color-surface-sunken, #171717);
27
+ font-family: inherit;
28
+ }
29
+
30
+ /*
31
+ * Leaflet ships its attribution link at #0078a8 on #333, which is 2.55:1
32
+ * against the surrounding text — below the 3:1 WCAG requires of a link
33
+ * distinguished by colour alone. This sheet is applied after Leaflet's, so
34
+ * underlining it satisfies the rule without depending on hue, and the
35
+ * control picks up the active theme instead of Leaflet's fixed palette.
36
+ */
37
+ .leaflet-container .leaflet-bottom.leaflet-right {
38
+ right: 0;
39
+ width: 100%;
40
+ pointer-events: none;
41
+ }
42
+
43
+ .leaflet-container .leaflet-control-attribution {
44
+ float: none;
45
+ box-sizing: border-box;
46
+ width: 100%;
47
+ max-width: none;
48
+ margin: 0;
49
+ padding: 4px 8px;
50
+ border: 0;
51
+ border-top: 1px solid var(--sigvelo-color-neutral-border-muted, rgb(255 255 255 / 15%));
52
+ border-radius: 0;
53
+ color: var(--sigvelo-color-text-muted, #b4b4b4);
54
+ background: color-mix(in srgb, var(--sigvelo-color-surface, #181818) 94%, transparent);
55
+ box-shadow: none;
56
+ font-size: 11px;
57
+ line-height: 1.35;
58
+ text-align: right;
59
+ white-space: normal;
60
+ pointer-events: auto;
61
+ }
62
+
63
+ .leaflet-container .leaflet-control-attribution a {
64
+ color: var(--sigvelo-color-primary-text, #ececec);
65
+ text-decoration: underline;
66
+ text-underline-offset: 2px;
67
+ }
68
+
69
+ .leaflet-container .leaflet-bar {
70
+ overflow: hidden;
71
+ border: 1px solid var(--sigvelo-color-neutral-border-muted, rgb(255 255 255 / 15%));
72
+ border-radius: var(--sigvelo-radius-sm, 4px);
73
+ box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
74
+ }
75
+
76
+ .leaflet-container .leaflet-bar a,
77
+ .leaflet-container .leaflet-bar a:hover {
78
+ border-bottom-color: var(--sigvelo-color-neutral-border-muted, rgb(255 255 255 / 15%));
79
+ color: var(--sigvelo-color-text, #ececec);
80
+ background: var(--sigvelo-color-surface, #181818);
81
+ }
82
+
83
+ .leaflet-container .leaflet-bar a:hover {
84
+ background: var(--sigvelo-color-surface-raised, #282828);
85
+ }
86
+
87
+ .leaflet-container .leaflet-popup-content-wrapper,
88
+ .leaflet-container .leaflet-popup-tip {
89
+ color: #171717;
90
+ background: #fcfcfc;
91
+ }
92
+
93
+ .leaflet-container .leaflet-popup-close-button,
94
+ .leaflet-container .leaflet-popup-close-button:hover {
95
+ color: #595959;
96
+ }
97
+ `;
98
+ //#endregion
99
+ //#region src/components/map/map.ts
100
+ const leafletCssWithAssets = leafletCss.replace(/url\(images\/layers-2x\.png\)/g, `url(${layersIcon2xUrl})`).replace(/url\(images\/layers\.png\)/g, `url(${layersIconUrl})`).replace(/url\(images\/marker-icon\.png\)/g, `url(${iconUrl})`);
101
+ let SigveloLeafletMap = class SigveloLeafletMap extends GeoMapElement {
102
+ constructor(..._args) {
103
+ super(..._args);
104
+ this.zoomControl = true;
105
+ this.attributionControl = true;
106
+ this._map = null;
107
+ }
108
+ static {
109
+ this.styles = [
110
+ ...GeoMapElement.styles,
111
+ unsafeCSS(leafletCssWithAssets),
112
+ map_styles_default
113
+ ];
114
+ }
115
+ /** Access the underlying Leaflet map instance (after mapReady resolves). */
116
+ get map() {
117
+ return this._map;
118
+ }
119
+ createMap(container) {
120
+ this._map = L.map(container, {
121
+ center: [this.latitude, this.longitude],
122
+ zoom: this.zoom,
123
+ minZoom: this.minZoom,
124
+ maxZoom: this.maxZoom,
125
+ zoomControl: this.zoomControl,
126
+ attributionControl: this.attributionControl
127
+ });
128
+ this._map.on("click", (e) => {
129
+ this.dispatchEvent(new SigveloMapClickEvent({
130
+ lat: e.latlng.lat,
131
+ lng: e.latlng.lng
132
+ }, e.originalEvent));
133
+ });
134
+ this._map.on("move", () => {
135
+ if (!this._map) return;
136
+ const center = this._map.getCenter();
137
+ this._suppressExternalUpdate = true;
138
+ this.latitude = center.lat;
139
+ this.longitude = center.lng;
140
+ this._suppressExternalUpdate = false;
141
+ this.dispatchEvent(new SigveloMapMoveEvent({
142
+ lat: center.lat,
143
+ lng: center.lng
144
+ }));
145
+ });
146
+ this._map.on("moveend", () => {
147
+ if (!this._map) return;
148
+ const center = this._map.getCenter();
149
+ this.dispatchEvent(new SigveloMapMoveEndEvent({
150
+ lat: center.lat,
151
+ lng: center.lng
152
+ }));
153
+ });
154
+ this._map.on("zoom", () => {
155
+ if (!this._map) return;
156
+ const zoom = this._map.getZoom();
157
+ this._suppressExternalUpdate = true;
158
+ this.zoom = zoom;
159
+ this._suppressExternalUpdate = false;
160
+ this.dispatchEvent(new SigveloMapZoomEvent(zoom));
161
+ });
162
+ this._map.on("zoomend", () => {
163
+ if (!this._map) return;
164
+ this.dispatchEvent(new SigveloMapZoomEndEvent(this._map.getZoom()));
165
+ });
166
+ this._map.whenReady(() => {
167
+ this._resolveMapReady();
168
+ this.dispatchEvent(new SigveloMapLoadEvent());
169
+ });
170
+ }
171
+ destroyMap() {
172
+ this._map?.remove();
173
+ this._map = null;
174
+ }
175
+ updateView(changed) {
176
+ if (!this._map) return;
177
+ if (changed.has("latitude") || changed.has("longitude") || changed.has("zoom")) this._map.setView([this.latitude, this.longitude], this.zoom);
178
+ if (changed.has("minZoom")) this._map.setMinZoom(this.minZoom);
179
+ if (changed.has("maxZoom")) this._map.setMaxZoom(this.maxZoom);
180
+ }
181
+ invalidateSize() {
182
+ this._map?.invalidateSize();
183
+ }
184
+ flyTo(options) {
185
+ this._map?.flyTo([options.center.lat, options.center.lng], options.zoom, { duration: options.duration ? options.duration / 1e3 : void 0 });
186
+ }
187
+ fitBounds(options) {
188
+ this._map?.fitBounds([[options.bounds.south, options.bounds.west], [options.bounds.north, options.bounds.east]], {
189
+ padding: options.padding ? [options.padding, options.padding] : void 0,
190
+ maxZoom: options.maxZoom
191
+ });
192
+ }
193
+ };
194
+ __decorate([property({
195
+ attribute: "zoom-control",
196
+ type: Boolean
197
+ })], SigveloLeafletMap.prototype, "zoomControl", void 0);
198
+ __decorate([property({
199
+ attribute: "attribution-control",
200
+ type: Boolean
201
+ })], SigveloLeafletMap.prototype, "attributionControl", void 0);
202
+ SigveloLeafletMap = __decorate([customElement("sigvelo-leaflet-map")], SigveloLeafletMap);
203
+ //#endregion
204
+ export { SigveloLeafletMap as t };
@@ -0,0 +1,115 @@
1
+ import "./default-icon.js";
2
+ import { t as __decorate } from "./decorate-DcF3lt7P.js";
3
+ import { findLeafletMap } from "./components/find-leaflet-map.js";
4
+ import * as L from "leaflet";
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 marker_styles_default = css`
9
+ :host {
10
+ display: none;
11
+ }
12
+ `;
13
+ //#endregion
14
+ //#region src/components/marker/marker.ts
15
+ let SigveloLeafletMarker = class SigveloLeafletMarker extends LitElement {
16
+ constructor(..._args) {
17
+ super(..._args);
18
+ this.latitude = 0;
19
+ this.longitude = 0;
20
+ this.title = "";
21
+ this.draggable = false;
22
+ this.opacity = 1;
23
+ this.iconUrl = "";
24
+ this.iconWidth = 25;
25
+ this.iconHeight = 41;
26
+ this._marker = null;
27
+ this._mapEl = null;
28
+ }
29
+ static {
30
+ this.styles = [marker_styles_default];
31
+ }
32
+ /** Access the underlying Leaflet marker instance. */
33
+ get marker() {
34
+ return this._marker;
35
+ }
36
+ async connectedCallback() {
37
+ super.connectedCallback();
38
+ this._mapEl = findLeafletMap(this);
39
+ if (this._mapEl) {
40
+ await this._mapEl.mapReady;
41
+ if (!this.isConnected) return;
42
+ this._addMarker();
43
+ }
44
+ }
45
+ disconnectedCallback() {
46
+ super.disconnectedCallback();
47
+ this._removeMarker();
48
+ }
49
+ /** @internal */
50
+ _addMarker() {
51
+ this._removeMarker();
52
+ if (!this._mapEl?.map) return;
53
+ const options = {
54
+ title: this.title,
55
+ draggable: this.draggable,
56
+ opacity: this.opacity
57
+ };
58
+ if (this.iconUrl) options.icon = L.icon({
59
+ iconUrl: this.iconUrl,
60
+ iconSize: [this.iconWidth, this.iconHeight],
61
+ iconAnchor: [this.iconWidth / 2, this.iconHeight],
62
+ popupAnchor: [0, -this.iconHeight]
63
+ });
64
+ this._marker = L.marker([this.latitude, this.longitude], options).addTo(this._mapEl.map);
65
+ this._bindChildPopup();
66
+ this._marker.on("dragend", () => {
67
+ if (!this._marker) return;
68
+ const pos = this._marker.getLatLng();
69
+ this.latitude = pos.lat;
70
+ this.longitude = pos.lng;
71
+ });
72
+ }
73
+ /** @internal */
74
+ _removeMarker() {
75
+ this._marker?.remove();
76
+ this._marker = null;
77
+ }
78
+ /** @internal */
79
+ _bindChildPopup() {
80
+ if (!this._marker) return;
81
+ const popupEl = this.querySelector("sigvelo-leaflet-popup");
82
+ if (popupEl) {
83
+ const content = document.createElement("div");
84
+ content.append(...Array.from(popupEl.childNodes).map((n) => n.cloneNode(true)));
85
+ this._marker.bindPopup(content);
86
+ }
87
+ }
88
+ updated() {
89
+ if (this._marker) {
90
+ this._marker.setLatLng([this.latitude, this.longitude]);
91
+ this._marker.setOpacity(this.opacity);
92
+ this._bindChildPopup();
93
+ }
94
+ }
95
+ render() {
96
+ return html` <slot></slot> `;
97
+ }
98
+ };
99
+ __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "latitude", void 0);
100
+ __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "longitude", void 0);
101
+ __decorate([property()], SigveloLeafletMarker.prototype, "title", void 0);
102
+ __decorate([property({ type: Boolean })], SigveloLeafletMarker.prototype, "draggable", void 0);
103
+ __decorate([property({ type: Number })], SigveloLeafletMarker.prototype, "opacity", void 0);
104
+ __decorate([property({ attribute: "icon-url" })], SigveloLeafletMarker.prototype, "iconUrl", void 0);
105
+ __decorate([property({
106
+ attribute: "icon-width",
107
+ type: Number
108
+ })], SigveloLeafletMarker.prototype, "iconWidth", void 0);
109
+ __decorate([property({
110
+ attribute: "icon-height",
111
+ type: Number
112
+ })], SigveloLeafletMarker.prototype, "iconHeight", void 0);
113
+ SigveloLeafletMarker = __decorate([customElement("sigvelo-leaflet-marker")], SigveloLeafletMarker);
114
+ //#endregion
115
+ export { SigveloLeafletMarker as t };
@@ -0,0 +1,78 @@
1
+ import { t as __decorate } from "./decorate-DcF3lt7P.js";
2
+ import { findLeafletMap } from "./components/find-leaflet-map.js";
3
+ import * as L from "leaflet";
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 polygon_styles_default = css`
8
+ :host {
9
+ display: none;
10
+ }
11
+ `;
12
+ //#endregion
13
+ //#region src/components/polygon/polygon.ts
14
+ let SigveloLeafletPolygon = class SigveloLeafletPolygon extends LitElement {
15
+ constructor(..._args) {
16
+ super(..._args);
17
+ this.positions = [];
18
+ this.fillColor = "#3388ff";
19
+ this.fillOpacity = .2;
20
+ this.strokeColor = "#3388ff";
21
+ this.strokeWidth = 3;
22
+ this._polygon = null;
23
+ this._mapEl = null;
24
+ }
25
+ static {
26
+ this.styles = [polygon_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._addPolygon();
34
+ }
35
+ }
36
+ disconnectedCallback() {
37
+ super.disconnectedCallback();
38
+ this._polygon?.remove();
39
+ this._polygon = null;
40
+ }
41
+ /** @internal */
42
+ _addPolygon() {
43
+ if (!this._mapEl?.map) return;
44
+ this._polygon = L.polygon(this.positions, {
45
+ fillColor: this.fillColor,
46
+ fillOpacity: this.fillOpacity,
47
+ color: this.strokeColor,
48
+ weight: this.strokeWidth
49
+ }).addTo(this._mapEl.map);
50
+ }
51
+ updated(changed) {
52
+ if (!this._polygon) return;
53
+ if (changed.has("positions")) this._polygon.setLatLngs(this.positions);
54
+ if (changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth")) this._polygon.setStyle({
55
+ fillColor: this.fillColor,
56
+ fillOpacity: this.fillOpacity,
57
+ color: this.strokeColor,
58
+ weight: this.strokeWidth
59
+ });
60
+ }
61
+ render() {
62
+ return html``;
63
+ }
64
+ };
65
+ __decorate([property({ attribute: false })], SigveloLeafletPolygon.prototype, "positions", void 0);
66
+ __decorate([property({ attribute: "fill-color" })], SigveloLeafletPolygon.prototype, "fillColor", void 0);
67
+ __decorate([property({
68
+ attribute: "fill-opacity",
69
+ type: Number
70
+ })], SigveloLeafletPolygon.prototype, "fillOpacity", void 0);
71
+ __decorate([property({ attribute: "stroke-color" })], SigveloLeafletPolygon.prototype, "strokeColor", void 0);
72
+ __decorate([property({
73
+ attribute: "stroke-width",
74
+ type: Number
75
+ })], SigveloLeafletPolygon.prototype, "strokeWidth", void 0);
76
+ SigveloLeafletPolygon = __decorate([customElement("sigvelo-leaflet-polygon")], SigveloLeafletPolygon);
77
+ //#endregion
78
+ export { SigveloLeafletPolygon as t };
@@ -0,0 +1,72 @@
1
+ import { t as __decorate } from "./decorate-DcF3lt7P.js";
2
+ import { findLeafletMap } from "./components/find-leaflet-map.js";
3
+ import * as L from "leaflet";
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 polyline_styles_default = css`
8
+ :host {
9
+ display: none;
10
+ }
11
+ `;
12
+ //#endregion
13
+ //#region src/components/polyline/polyline.ts
14
+ let SigveloLeafletPolyline = class SigveloLeafletPolyline extends LitElement {
15
+ constructor(..._args) {
16
+ super(..._args);
17
+ this.positions = [];
18
+ this.color = "#3388ff";
19
+ this.weight = 3;
20
+ this.opacity = 1;
21
+ this.dashArray = "";
22
+ this._polyline = null;
23
+ this._mapEl = null;
24
+ }
25
+ static {
26
+ this.styles = [polyline_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._addPolyline();
34
+ }
35
+ }
36
+ disconnectedCallback() {
37
+ super.disconnectedCallback();
38
+ this._polyline?.remove();
39
+ this._polyline = null;
40
+ }
41
+ /** @internal */
42
+ _addPolyline() {
43
+ if (!this._mapEl?.map) return;
44
+ this._polyline = L.polyline(this.positions, {
45
+ color: this.color,
46
+ weight: this.weight,
47
+ opacity: this.opacity,
48
+ dashArray: this.dashArray || void 0
49
+ }).addTo(this._mapEl.map);
50
+ }
51
+ updated(changed) {
52
+ if (!this._polyline) return;
53
+ if (changed.has("positions")) this._polyline.setLatLngs(this.positions);
54
+ if (changed.has("color") || changed.has("weight") || changed.has("opacity") || changed.has("dashArray")) this._polyline.setStyle({
55
+ color: this.color,
56
+ weight: this.weight,
57
+ opacity: this.opacity,
58
+ dashArray: this.dashArray || void 0
59
+ });
60
+ }
61
+ render() {
62
+ return html``;
63
+ }
64
+ };
65
+ __decorate([property({ attribute: false })], SigveloLeafletPolyline.prototype, "positions", void 0);
66
+ __decorate([property()], SigveloLeafletPolyline.prototype, "color", void 0);
67
+ __decorate([property({ type: Number })], SigveloLeafletPolyline.prototype, "weight", void 0);
68
+ __decorate([property({ type: Number })], SigveloLeafletPolyline.prototype, "opacity", void 0);
69
+ __decorate([property({ attribute: "dash-array" })], SigveloLeafletPolyline.prototype, "dashArray", void 0);
70
+ SigveloLeafletPolyline = __decorate([customElement("sigvelo-leaflet-polyline")], SigveloLeafletPolyline);
71
+ //#endregion
72
+ export { SigveloLeafletPolyline as t };