@mcp-b/geo-maplibre 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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/dist/circle-CFH3gDcY.js +146 -0
  3. package/dist/components/circle/circle.d.ts +51 -0
  4. package/dist/components/circle/circle.js +2 -0
  5. package/dist/components/control/control.d.ts +42 -0
  6. package/dist/components/control/control.js +2 -0
  7. package/dist/components/geojson/geojson.d.ts +74 -0
  8. package/dist/components/geojson/geojson.js +2 -0
  9. package/dist/components/layer/layer.d.ts +35 -0
  10. package/dist/components/layer/layer.js +2 -0
  11. package/dist/components/map/map.d.ts +43 -0
  12. package/dist/components/map/map.js +2 -0
  13. package/dist/components/marker/marker.d.ts +42 -0
  14. package/dist/components/marker/marker.js +2 -0
  15. package/dist/components/polygon/polygon.d.ts +46 -0
  16. package/dist/components/polygon/polygon.js +2 -0
  17. package/dist/components/polyline/polyline.d.ts +44 -0
  18. package/dist/components/polyline/polyline.js +2 -0
  19. package/dist/components/popup/popup.d.ts +27 -0
  20. package/dist/components/popup/popup.js +2 -0
  21. package/dist/components/scale-control/scale-control.d.ts +33 -0
  22. package/dist/components/scale-control/scale-control.js +2 -0
  23. package/dist/components/tilelayer/tilelayer.d.ts +65 -0
  24. package/dist/components/tilelayer/tilelayer.js +2 -0
  25. package/dist/control-Bka68vGo.js +61 -0
  26. package/dist/decorate-DcF3lt7P.js +9 -0
  27. package/dist/docs/custom-elements.json +1596 -0
  28. package/dist/geojson-BW9JQxtv.js +240 -0
  29. package/dist/index.d.ts +12 -0
  30. package/dist/index.js +12 -0
  31. package/dist/layer-COvBRP1h.js +61 -0
  32. package/dist/map-CYqh-osb.js +135 -0
  33. package/dist/marker-DzWveHNW.js +79 -0
  34. package/dist/polygon-BJ-z1X7p.js +119 -0
  35. package/dist/polyline-Dt4yBInz.js +98 -0
  36. package/dist/popup-BNRD9rNd.js +30 -0
  37. package/dist/scale-control-DPWq0EHU.js +58 -0
  38. package/dist/tilelayer-CCmClbSv.js +85 -0
  39. package/package.json +75 -0
@@ -0,0 +1,98 @@
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/polyline/polyline.styles.ts
5
+ var polyline_styles_default = css`
6
+ :host {
7
+ display: none;
8
+ }
9
+ `;
10
+ //#endregion
11
+ //#region src/components/polyline/polyline.ts
12
+ let lineCounter = 0;
13
+ let SigveloMaplibrePolyline = class SigveloMaplibrePolyline extends LitElement {
14
+ static {
15
+ this.styles = [polyline_styles_default];
16
+ }
17
+ constructor() {
18
+ super();
19
+ this.positions = [];
20
+ this.color = "#3388ff";
21
+ this.width = 3;
22
+ this.opacity = 1;
23
+ this.dashArray = [];
24
+ this._mapEl = null;
25
+ const id = ++lineCounter;
26
+ this._sourceId = `sigvelo-line-source-${id}`;
27
+ this._layerId = `sigvelo-line-layer-${id}`;
28
+ }
29
+ async connectedCallback() {
30
+ super.connectedCallback();
31
+ this._mapEl = this.closest("sigvelo-maplibre-map");
32
+ if (this._mapEl) {
33
+ await this._mapEl.mapReady;
34
+ this._addLine();
35
+ }
36
+ }
37
+ disconnectedCallback() {
38
+ super.disconnectedCallback();
39
+ this._removeLine();
40
+ }
41
+ _toGeoJSON() {
42
+ return {
43
+ type: "Feature",
44
+ geometry: {
45
+ type: "LineString",
46
+ coordinates: this.positions.map(([lat, lng]) => [lng, lat])
47
+ },
48
+ properties: {}
49
+ };
50
+ }
51
+ _addLine() {
52
+ const map = this._mapEl?.map;
53
+ if (!map || this.positions.length < 2) return;
54
+ map.addSource(this._sourceId, {
55
+ type: "geojson",
56
+ data: this._toGeoJSON()
57
+ });
58
+ map.addLayer({
59
+ id: this._layerId,
60
+ type: "line",
61
+ source: this._sourceId,
62
+ paint: {
63
+ "line-color": this.color,
64
+ "line-width": this.width,
65
+ "line-opacity": this.opacity,
66
+ ...this.dashArray.length ? { "line-dasharray": this.dashArray } : {}
67
+ }
68
+ });
69
+ }
70
+ _removeLine() {
71
+ const map = this._mapEl?.map;
72
+ if (!map) return;
73
+ if (map.getLayer(this._layerId)) map.removeLayer(this._layerId);
74
+ if (map.getSource(this._sourceId)) map.removeSource(this._sourceId);
75
+ }
76
+ updated(changed) {
77
+ const map = this._mapEl?.map;
78
+ if (!map) return;
79
+ if (changed.has("positions")) {
80
+ const source = map.getSource(this._sourceId);
81
+ if (source) source.setData(this._toGeoJSON());
82
+ }
83
+ if (changed.has("color") && map.getLayer(this._layerId)) map.setPaintProperty(this._layerId, "line-color", this.color);
84
+ if (changed.has("width") && map.getLayer(this._layerId)) map.setPaintProperty(this._layerId, "line-width", this.width);
85
+ if (changed.has("opacity") && map.getLayer(this._layerId)) map.setPaintProperty(this._layerId, "line-opacity", this.opacity);
86
+ }
87
+ render() {
88
+ return html``;
89
+ }
90
+ };
91
+ __decorate([property({ attribute: false })], SigveloMaplibrePolyline.prototype, "positions", void 0);
92
+ __decorate([property()], SigveloMaplibrePolyline.prototype, "color", void 0);
93
+ __decorate([property({ type: Number })], SigveloMaplibrePolyline.prototype, "width", void 0);
94
+ __decorate([property({ type: Number })], SigveloMaplibrePolyline.prototype, "opacity", void 0);
95
+ __decorate([property({ attribute: false })], SigveloMaplibrePolyline.prototype, "dashArray", void 0);
96
+ SigveloMaplibrePolyline = __decorate([customElement("sigvelo-maplibre-polyline")], SigveloMaplibrePolyline);
97
+ //#endregion
98
+ export { SigveloMaplibrePolyline as t };
@@ -0,0 +1,30 @@
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 SigveloMaplibrePopup = class SigveloMaplibrePopup extends LitElement {
13
+ constructor(..._args) {
14
+ super(..._args);
15
+ this.maxWidth = 300;
16
+ }
17
+ static {
18
+ this.styles = [popup_styles_default];
19
+ }
20
+ render() {
21
+ return html` <slot></slot> `;
22
+ }
23
+ };
24
+ __decorate([property({
25
+ attribute: "max-width",
26
+ type: Number
27
+ })], SigveloMaplibrePopup.prototype, "maxWidth", void 0);
28
+ SigveloMaplibrePopup = __decorate([customElement("sigvelo-maplibre-popup")], SigveloMaplibrePopup);
29
+ //#endregion
30
+ export { SigveloMaplibrePopup as t };
@@ -0,0 +1,58 @@
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
+ import maplibregl from "maplibre-gl";
5
+ //#region src/components/scale-control/scale-control.styles.ts
6
+ var scale_control_styles_default = css`
7
+ :host {
8
+ display: none;
9
+ }
10
+ `;
11
+ //#endregion
12
+ //#region src/components/scale-control/scale-control.ts
13
+ let SigveloMaplibreScaleControl = class SigveloMaplibreScaleControl extends LitElement {
14
+ constructor(..._args) {
15
+ super(..._args);
16
+ this.position = "bottom-left";
17
+ this.unit = "metric";
18
+ this.maxWidth = 100;
19
+ this._control = null;
20
+ this._mapEl = null;
21
+ }
22
+ static {
23
+ this.styles = [scale_control_styles_default];
24
+ }
25
+ async connectedCallback() {
26
+ super.connectedCallback();
27
+ this._mapEl = this.closest("sigvelo-maplibre-map");
28
+ if (this._mapEl) {
29
+ await this._mapEl.mapReady;
30
+ this._addControl();
31
+ }
32
+ }
33
+ disconnectedCallback() {
34
+ super.disconnectedCallback();
35
+ if (this._control && this._mapEl?.map) this._mapEl.map.removeControl(this._control);
36
+ this._control = null;
37
+ }
38
+ _addControl() {
39
+ if (!this._mapEl?.map) return;
40
+ this._control = new maplibregl.ScaleControl({
41
+ maxWidth: this.maxWidth,
42
+ unit: this.unit
43
+ });
44
+ this._mapEl.map.addControl(this._control, this.position);
45
+ }
46
+ render() {
47
+ return html``;
48
+ }
49
+ };
50
+ __decorate([property()], SigveloMaplibreScaleControl.prototype, "position", void 0);
51
+ __decorate([property()], SigveloMaplibreScaleControl.prototype, "unit", void 0);
52
+ __decorate([property({
53
+ attribute: "max-width",
54
+ type: Number
55
+ })], SigveloMaplibreScaleControl.prototype, "maxWidth", void 0);
56
+ SigveloMaplibreScaleControl = __decorate([customElement("sigvelo-maplibre-scale-control")], SigveloMaplibreScaleControl);
57
+ //#endregion
58
+ export { SigveloMaplibreScaleControl as t };
@@ -0,0 +1,85 @@
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/tilelayer/tilelayer.styles.ts
5
+ var tilelayer_styles_default = css`
6
+ :host {
7
+ display: none;
8
+ }
9
+ `;
10
+ //#endregion
11
+ //#region src/components/tilelayer/tilelayer.ts
12
+ let SigveloMaplibreTilelayer = class SigveloMaplibreTilelayer extends LitElement {
13
+ constructor(..._args) {
14
+ super(..._args);
15
+ this.styleUrl = "";
16
+ this.url = "";
17
+ this.attribution = "";
18
+ this.opacity = 1;
19
+ this._rasterSourceId = "sigvelo-raster-source";
20
+ this._rasterLayerId = "sigvelo-raster-layer";
21
+ this._mapEl = null;
22
+ }
23
+ static {
24
+ this.styles = [tilelayer_styles_default];
25
+ }
26
+ async connectedCallback() {
27
+ super.connectedCallback();
28
+ this._mapEl = this.closest("sigvelo-maplibre-map");
29
+ if (this._mapEl) {
30
+ await this._mapEl.mapReady;
31
+ this._applyTiles();
32
+ }
33
+ }
34
+ disconnectedCallback() {
35
+ super.disconnectedCallback();
36
+ this._removeRasterLayer();
37
+ }
38
+ _applyTiles() {
39
+ const map = this._mapEl?.map;
40
+ if (!map) return;
41
+ if (this.styleUrl) map.setStyle(this.styleUrl);
42
+ else if (this.url) this._addRasterLayer();
43
+ }
44
+ _addRasterLayer() {
45
+ const map = this._mapEl?.map;
46
+ if (!map || !this.url) return;
47
+ if (!map.isStyleLoaded()) return;
48
+ this._removeRasterLayer();
49
+ map.addSource(this._rasterSourceId, {
50
+ type: "raster",
51
+ tiles: [this.url],
52
+ tileSize: 256,
53
+ attribution: this.attribution || void 0
54
+ });
55
+ map.addLayer({
56
+ id: this._rasterLayerId,
57
+ type: "raster",
58
+ source: this._rasterSourceId,
59
+ paint: { "raster-opacity": this.opacity }
60
+ });
61
+ }
62
+ _removeRasterLayer() {
63
+ const map = this._mapEl?.map;
64
+ if (!map) return;
65
+ if (map.getLayer(this._rasterLayerId)) map.removeLayer(this._rasterLayerId);
66
+ if (map.getSource(this._rasterSourceId)) map.removeSource(this._rasterSourceId);
67
+ }
68
+ updated(changed) {
69
+ if (changed.has("styleUrl") || changed.has("url")) this._applyTiles();
70
+ if (changed.has("opacity") && this._mapEl?.map) {
71
+ const map = this._mapEl.map;
72
+ if (map.getLayer(this._rasterLayerId)) map.setPaintProperty(this._rasterLayerId, "raster-opacity", this.opacity);
73
+ }
74
+ }
75
+ render() {
76
+ return html``;
77
+ }
78
+ };
79
+ __decorate([property({ attribute: "style-url" })], SigveloMaplibreTilelayer.prototype, "styleUrl", void 0);
80
+ __decorate([property()], SigveloMaplibreTilelayer.prototype, "url", void 0);
81
+ __decorate([property()], SigveloMaplibreTilelayer.prototype, "attribution", void 0);
82
+ __decorate([property({ type: Number })], SigveloMaplibreTilelayer.prototype, "opacity", void 0);
83
+ SigveloMaplibreTilelayer = __decorate([customElement("sigvelo-maplibre-tilelayer")], SigveloMaplibreTilelayer);
84
+ //#endregion
85
+ export { SigveloMaplibreTilelayer as t };
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@mcp-b/geo-maplibre",
3
+ "version": "0.2.0",
4
+ "description": "MapLibre GL JS web components for Sigvelo, built with Lit.",
5
+ "keywords": [
6
+ "custom-elements",
7
+ "geospatial",
8
+ "lit-element",
9
+ "maplibre",
10
+ "maps",
11
+ "web-components",
12
+ "webgl"
13
+ ],
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/WebMCP-org/design-system.git",
18
+ "directory": "packages/geo-maplibre"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "type": "module",
24
+ "types": "dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./components/*": "./dist/components/*",
31
+ "./custom-elements.json": "./dist/docs/custom-elements.json"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "@mcp-b/geo-support": "0.2.0",
38
+ "@mcp-b/wc-support": "0.2.0"
39
+ },
40
+ "devDependencies": {
41
+ "@custom-elements-manifest/analyzer": "^0.10.4",
42
+ "@storybook/addon-a11y": "^10.5.2",
43
+ "@storybook/addon-docs": "^10.5.2",
44
+ "@storybook/addon-vitest": "^10.5.2",
45
+ "@storybook/web-components-vite": "10.5.2",
46
+ "@vitest/browser-playwright": "^4.1.10",
47
+ "@vitest/coverage-v8": "^4.1.10",
48
+ "@wc-toolkit/cem-inheritance": "^1.2.2",
49
+ "@wc-toolkit/cem-sorter": "^1.0.1",
50
+ "@wc-toolkit/type-parser": "^1.2.0",
51
+ "maplibre-gl": "^5.5.0",
52
+ "playwright": "~1.61.0",
53
+ "storybook": "^10.5.2",
54
+ "tinyglobby": "^0.2.15",
55
+ "typescript": "^6.0.3",
56
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
57
+ "vite-plugin-static-copy": "^3.3.0",
58
+ "vitest": "^4.1.10"
59
+ },
60
+ "peerDependencies": {
61
+ "lit": "^3.0.0",
62
+ "lit-html": "^3.0.0",
63
+ "maplibre-gl": "^5.0.0"
64
+ },
65
+ "customElements": "dist/docs/custom-elements.json",
66
+ "scripts": {
67
+ "analyze": "cem analyze",
68
+ "analyze:dev": "cem analyze --watch",
69
+ "build": "tsc -p tsconfig.prod.json && vp run build:lib && vp run analyze",
70
+ "build:lib": "vp pack",
71
+ "storybook": "vp run @mcp-b/web-components#storybook",
72
+ "test": "vp run @mcp-b/web-components#test",
73
+ "typecheck": "tsc --noEmit"
74
+ }
75
+ }