@mcp-b/geo-maplibre 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.
- package/dist/components/circle/circle.js +137 -1
- package/dist/components/control/control.d.ts +7 -2
- package/dist/components/control/control.js +66 -1
- package/dist/components/geojson/geojson.js +232 -1
- package/dist/components/layer/layer.js +52 -1
- package/dist/components/map/map.js +121 -1
- package/dist/components/marker/marker.js +66 -1
- package/dist/components/polygon/polygon.js +110 -1
- package/dist/components/polyline/polyline.js +89 -1
- package/dist/components/popup/popup.js +23 -1
- package/dist/components/scale-control/scale-control.d.ts +2 -1
- package/dist/components/scale-control/scale-control.js +49 -1
- package/dist/components/tilelayer/tilelayer.js +76 -1
- package/dist/docs/custom-elements.json +23 -3
- package/dist/index.js +11 -11
- package/package.json +3 -3
- package/dist/circle-CFH3gDcY.js +0 -146
- package/dist/control-Bka68vGo.js +0 -61
- package/dist/geojson-BW9JQxtv.js +0 -240
- package/dist/layer-COvBRP1h.js +0 -61
- package/dist/map-CYqh-osb.js +0 -135
- package/dist/marker-DzWveHNW.js +0 -79
- package/dist/polygon-BJ-z1X7p.js +0 -119
- package/dist/polyline-Dt4yBInz.js +0 -98
- package/dist/popup-BNRD9rNd.js +0 -30
- package/dist/scale-control-DPWq0EHU.js +0 -58
- package/dist/tilelayer-CCmClbSv.js +0 -85
|
@@ -1,2 +1,67 @@
|
|
|
1
|
-
import { t as
|
|
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 maplibregl from "maplibre-gl";
|
|
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
|
+
import { clonePopupContent } from "@mcp-b/geo-support/base/popup-content";
|
|
8
|
+
//#region src/components/marker/marker.ts
|
|
9
|
+
let SigveloMaplibreMarker = class SigveloMaplibreMarker extends LitElement {
|
|
10
|
+
constructor(..._args) {
|
|
11
|
+
super(..._args);
|
|
12
|
+
this.latitude = 0;
|
|
13
|
+
this.longitude = 0;
|
|
14
|
+
this.color = "#3fb1ce";
|
|
15
|
+
this.draggable = false;
|
|
16
|
+
this.scale = 1;
|
|
17
|
+
this._marker = null;
|
|
18
|
+
this._mapEl = null;
|
|
19
|
+
}
|
|
20
|
+
static {
|
|
21
|
+
this.styles = [styles];
|
|
22
|
+
}
|
|
23
|
+
/** Access the underlying MapLibre marker instance. */
|
|
24
|
+
get marker() {
|
|
25
|
+
return this._marker;
|
|
26
|
+
}
|
|
27
|
+
async connectedCallback() {
|
|
28
|
+
super.connectedCallback();
|
|
29
|
+
this._mapEl = findMapElement(this, "sigvelo-maplibre-map");
|
|
30
|
+
await this._mapEl?.whenMapReady(this, () => this._addMarker());
|
|
31
|
+
}
|
|
32
|
+
disconnectedCallback() {
|
|
33
|
+
super.disconnectedCallback();
|
|
34
|
+
this._marker?.remove();
|
|
35
|
+
this._marker = null;
|
|
36
|
+
}
|
|
37
|
+
_addMarker() {
|
|
38
|
+
if (!this._mapEl?.map) return;
|
|
39
|
+
this._marker = new maplibregl.Marker({
|
|
40
|
+
color: this.color,
|
|
41
|
+
draggable: this.draggable,
|
|
42
|
+
scale: this.scale
|
|
43
|
+
}).setLngLat([this.longitude, this.latitude]).addTo(this._mapEl.map);
|
|
44
|
+
const popupEl = this.querySelector("sigvelo-maplibre-popup");
|
|
45
|
+
if (popupEl) this._marker.setPopup(new maplibregl.Popup().setDOMContent(clonePopupContent(popupEl)));
|
|
46
|
+
this._marker.on("dragend", () => {
|
|
47
|
+
if (!this._marker) return;
|
|
48
|
+
const pos = this._marker.getLngLat();
|
|
49
|
+
this.latitude = pos.lat;
|
|
50
|
+
this.longitude = pos.lng;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
updated() {
|
|
54
|
+
if (this._marker) this._marker.setLngLat([this.longitude, this.latitude]);
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
return html` <slot></slot> `;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
__decorate([property({ type: Number })], SigveloMaplibreMarker.prototype, "latitude", void 0);
|
|
61
|
+
__decorate([property({ type: Number })], SigveloMaplibreMarker.prototype, "longitude", void 0);
|
|
62
|
+
__decorate([property()], SigveloMaplibreMarker.prototype, "color", void 0);
|
|
63
|
+
__decorate([property({ type: Boolean })], SigveloMaplibreMarker.prototype, "draggable", void 0);
|
|
64
|
+
__decorate([property({ type: Number })], SigveloMaplibreMarker.prototype, "scale", void 0);
|
|
65
|
+
SigveloMaplibreMarker = __decorate([customElement("sigvelo-maplibre-marker")], SigveloMaplibreMarker);
|
|
66
|
+
//#endregion
|
|
2
67
|
export { SigveloMaplibreMarker };
|
|
@@ -1,2 +1,111 @@
|
|
|
1
|
-
import { t as
|
|
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 { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
|
|
5
|
+
import styles from "@mcp-b/geo-support/styles/map-child.styles";
|
|
6
|
+
//#region src/components/polygon/polygon.ts
|
|
7
|
+
let polygonCounter = 0;
|
|
8
|
+
let SigveloMaplibrePolygon = class SigveloMaplibrePolygon extends LitElement {
|
|
9
|
+
static {
|
|
10
|
+
this.styles = [styles];
|
|
11
|
+
}
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.positions = [];
|
|
15
|
+
this.fillColor = "#3388ff";
|
|
16
|
+
this.fillOpacity = .2;
|
|
17
|
+
this.strokeColor = "#3388ff";
|
|
18
|
+
this.strokeWidth = 2;
|
|
19
|
+
this._mapEl = null;
|
|
20
|
+
const id = ++polygonCounter;
|
|
21
|
+
this._sourceId = `sigvelo-polygon-source-${id}`;
|
|
22
|
+
this._fillLayerId = `sigvelo-polygon-fill-${id}`;
|
|
23
|
+
this._strokeLayerId = `sigvelo-polygon-stroke-${id}`;
|
|
24
|
+
}
|
|
25
|
+
async connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
this._mapEl = findMapElement(this, "sigvelo-maplibre-map");
|
|
28
|
+
await this._mapEl?.whenMapReady(this, () => this._addPolygon());
|
|
29
|
+
}
|
|
30
|
+
disconnectedCallback() {
|
|
31
|
+
super.disconnectedCallback();
|
|
32
|
+
this._removePolygon();
|
|
33
|
+
}
|
|
34
|
+
_toGeoJSON() {
|
|
35
|
+
const ring = this.positions.map(([lat, lng]) => [lng, lat]);
|
|
36
|
+
if (ring.length > 0) {
|
|
37
|
+
const first = ring[0];
|
|
38
|
+
const last = ring[ring.length - 1];
|
|
39
|
+
if (first[0] !== last[0] || first[1] !== last[1]) ring.push([...first]);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
type: "Feature",
|
|
43
|
+
geometry: {
|
|
44
|
+
type: "Polygon",
|
|
45
|
+
coordinates: [ring]
|
|
46
|
+
},
|
|
47
|
+
properties: {}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
_addPolygon() {
|
|
51
|
+
const map = this._mapEl?.map;
|
|
52
|
+
if (!map || this.positions.length < 3) return;
|
|
53
|
+
map.addSource(this._sourceId, {
|
|
54
|
+
type: "geojson",
|
|
55
|
+
data: this._toGeoJSON()
|
|
56
|
+
});
|
|
57
|
+
map.addLayer({
|
|
58
|
+
id: this._fillLayerId,
|
|
59
|
+
type: "fill",
|
|
60
|
+
source: this._sourceId,
|
|
61
|
+
paint: {
|
|
62
|
+
"fill-color": this.fillColor,
|
|
63
|
+
"fill-opacity": this.fillOpacity
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
map.addLayer({
|
|
67
|
+
id: this._strokeLayerId,
|
|
68
|
+
type: "line",
|
|
69
|
+
source: this._sourceId,
|
|
70
|
+
paint: {
|
|
71
|
+
"line-color": this.strokeColor,
|
|
72
|
+
"line-width": this.strokeWidth
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
_removePolygon() {
|
|
77
|
+
const map = this._mapEl?.map;
|
|
78
|
+
if (!map) return;
|
|
79
|
+
for (const id of [this._fillLayerId, this._strokeLayerId]) if (map.getLayer(id)) map.removeLayer(id);
|
|
80
|
+
if (map.getSource(this._sourceId)) map.removeSource(this._sourceId);
|
|
81
|
+
}
|
|
82
|
+
updated(changed) {
|
|
83
|
+
const map = this._mapEl?.map;
|
|
84
|
+
if (!map) return;
|
|
85
|
+
if (changed.has("positions")) {
|
|
86
|
+
const source = map.getSource(this._sourceId);
|
|
87
|
+
if (source) source.setData(this._toGeoJSON());
|
|
88
|
+
}
|
|
89
|
+
if (changed.has("fillColor") && map.getLayer(this._fillLayerId)) map.setPaintProperty(this._fillLayerId, "fill-color", this.fillColor);
|
|
90
|
+
if (changed.has("fillOpacity") && map.getLayer(this._fillLayerId)) map.setPaintProperty(this._fillLayerId, "fill-opacity", this.fillOpacity);
|
|
91
|
+
if (changed.has("strokeColor") && map.getLayer(this._strokeLayerId)) map.setPaintProperty(this._strokeLayerId, "line-color", this.strokeColor);
|
|
92
|
+
if (changed.has("strokeWidth") && map.getLayer(this._strokeLayerId)) map.setPaintProperty(this._strokeLayerId, "line-width", this.strokeWidth);
|
|
93
|
+
}
|
|
94
|
+
render() {
|
|
95
|
+
return html``;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
__decorate([property({ attribute: false })], SigveloMaplibrePolygon.prototype, "positions", void 0);
|
|
99
|
+
__decorate([property({ attribute: "fill-color" })], SigveloMaplibrePolygon.prototype, "fillColor", void 0);
|
|
100
|
+
__decorate([property({
|
|
101
|
+
attribute: "fill-opacity",
|
|
102
|
+
type: Number
|
|
103
|
+
})], SigveloMaplibrePolygon.prototype, "fillOpacity", void 0);
|
|
104
|
+
__decorate([property({ attribute: "stroke-color" })], SigveloMaplibrePolygon.prototype, "strokeColor", void 0);
|
|
105
|
+
__decorate([property({
|
|
106
|
+
attribute: "stroke-width",
|
|
107
|
+
type: Number
|
|
108
|
+
})], SigveloMaplibrePolygon.prototype, "strokeWidth", void 0);
|
|
109
|
+
SigveloMaplibrePolygon = __decorate([customElement("sigvelo-maplibre-polygon")], SigveloMaplibrePolygon);
|
|
110
|
+
//#endregion
|
|
2
111
|
export { SigveloMaplibrePolygon };
|
|
@@ -1,2 +1,90 @@
|
|
|
1
|
-
import { t as
|
|
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 { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
|
|
5
|
+
import styles from "@mcp-b/geo-support/styles/map-child.styles";
|
|
6
|
+
//#region src/components/polyline/polyline.ts
|
|
7
|
+
let lineCounter = 0;
|
|
8
|
+
let SigveloMaplibrePolyline = class SigveloMaplibrePolyline extends LitElement {
|
|
9
|
+
static {
|
|
10
|
+
this.styles = [styles];
|
|
11
|
+
}
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.positions = [];
|
|
15
|
+
this.color = "#3388ff";
|
|
16
|
+
this.width = 3;
|
|
17
|
+
this.opacity = 1;
|
|
18
|
+
this.dashArray = [];
|
|
19
|
+
this._mapEl = null;
|
|
20
|
+
const id = ++lineCounter;
|
|
21
|
+
this._sourceId = `sigvelo-line-source-${id}`;
|
|
22
|
+
this._layerId = `sigvelo-line-layer-${id}`;
|
|
23
|
+
}
|
|
24
|
+
async connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
this._mapEl = findMapElement(this, "sigvelo-maplibre-map");
|
|
27
|
+
await this._mapEl?.whenMapReady(this, () => this._addLine());
|
|
28
|
+
}
|
|
29
|
+
disconnectedCallback() {
|
|
30
|
+
super.disconnectedCallback();
|
|
31
|
+
this._removeLine();
|
|
32
|
+
}
|
|
33
|
+
_toGeoJSON() {
|
|
34
|
+
return {
|
|
35
|
+
type: "Feature",
|
|
36
|
+
geometry: {
|
|
37
|
+
type: "LineString",
|
|
38
|
+
coordinates: this.positions.map(([lat, lng]) => [lng, lat])
|
|
39
|
+
},
|
|
40
|
+
properties: {}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
_addLine() {
|
|
44
|
+
const map = this._mapEl?.map;
|
|
45
|
+
if (!map || this.positions.length < 2) return;
|
|
46
|
+
map.addSource(this._sourceId, {
|
|
47
|
+
type: "geojson",
|
|
48
|
+
data: this._toGeoJSON()
|
|
49
|
+
});
|
|
50
|
+
map.addLayer({
|
|
51
|
+
id: this._layerId,
|
|
52
|
+
type: "line",
|
|
53
|
+
source: this._sourceId,
|
|
54
|
+
paint: {
|
|
55
|
+
"line-color": this.color,
|
|
56
|
+
"line-width": this.width,
|
|
57
|
+
"line-opacity": this.opacity,
|
|
58
|
+
...this.dashArray.length ? { "line-dasharray": this.dashArray } : {}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
_removeLine() {
|
|
63
|
+
const map = this._mapEl?.map;
|
|
64
|
+
if (!map) return;
|
|
65
|
+
if (map.getLayer(this._layerId)) map.removeLayer(this._layerId);
|
|
66
|
+
if (map.getSource(this._sourceId)) map.removeSource(this._sourceId);
|
|
67
|
+
}
|
|
68
|
+
updated(changed) {
|
|
69
|
+
const map = this._mapEl?.map;
|
|
70
|
+
if (!map) return;
|
|
71
|
+
if (changed.has("positions")) {
|
|
72
|
+
const source = map.getSource(this._sourceId);
|
|
73
|
+
if (source) source.setData(this._toGeoJSON());
|
|
74
|
+
}
|
|
75
|
+
if (changed.has("color") && map.getLayer(this._layerId)) map.setPaintProperty(this._layerId, "line-color", this.color);
|
|
76
|
+
if (changed.has("width") && map.getLayer(this._layerId)) map.setPaintProperty(this._layerId, "line-width", this.width);
|
|
77
|
+
if (changed.has("opacity") && map.getLayer(this._layerId)) map.setPaintProperty(this._layerId, "line-opacity", this.opacity);
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
return html``;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
__decorate([property({ attribute: false })], SigveloMaplibrePolyline.prototype, "positions", void 0);
|
|
84
|
+
__decorate([property()], SigveloMaplibrePolyline.prototype, "color", void 0);
|
|
85
|
+
__decorate([property({ type: Number })], SigveloMaplibrePolyline.prototype, "width", void 0);
|
|
86
|
+
__decorate([property({ type: Number })], SigveloMaplibrePolyline.prototype, "opacity", void 0);
|
|
87
|
+
__decorate([property({ attribute: false })], SigveloMaplibrePolyline.prototype, "dashArray", void 0);
|
|
88
|
+
SigveloMaplibrePolyline = __decorate([customElement("sigvelo-maplibre-polyline")], SigveloMaplibrePolyline);
|
|
89
|
+
//#endregion
|
|
2
90
|
export { SigveloMaplibrePolyline };
|
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
import { t as
|
|
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 SigveloMaplibrePopup = class SigveloMaplibrePopup extends LitElement {
|
|
7
|
+
constructor(..._args) {
|
|
8
|
+
super(..._args);
|
|
9
|
+
this.maxWidth = 300;
|
|
10
|
+
}
|
|
11
|
+
static {
|
|
12
|
+
this.styles = [styles];
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
return html` <slot></slot> `;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
__decorate([property({
|
|
19
|
+
attribute: "max-width",
|
|
20
|
+
type: Number
|
|
21
|
+
})], SigveloMaplibrePopup.prototype, "maxWidth", void 0);
|
|
22
|
+
SigveloMaplibrePopup = __decorate([customElement("sigvelo-maplibre-popup")], SigveloMaplibrePopup);
|
|
23
|
+
//#endregion
|
|
2
24
|
export { SigveloMaplibrePopup };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
+
import { ControlPosition } from "@mcp-b/geo-support/types";
|
|
2
3
|
|
|
3
4
|
//#region src/components/scale-control/scale-control.d.ts
|
|
4
5
|
/**
|
|
@@ -10,7 +11,7 @@ declare class SigveloMaplibreScaleControl extends LitElement {
|
|
|
10
11
|
/** @internal */
|
|
11
12
|
static styles: import("lit").CSSResult[];
|
|
12
13
|
/** Position of the control on the map. */
|
|
13
|
-
position:
|
|
14
|
+
position: ControlPosition;
|
|
14
15
|
/** Unit system for the scale bar. */
|
|
15
16
|
unit: "imperial" | "metric" | "nautical";
|
|
16
17
|
/** Maximum width of the scale bar in pixels. */
|
|
@@ -1,2 +1,50 @@
|
|
|
1
|
-
import { t as
|
|
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 maplibregl from "maplibre-gl";
|
|
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/scale-control/scale-control.ts
|
|
8
|
+
let SigveloMaplibreScaleControl = class SigveloMaplibreScaleControl extends LitElement {
|
|
9
|
+
constructor(..._args) {
|
|
10
|
+
super(..._args);
|
|
11
|
+
this.position = "bottom-left";
|
|
12
|
+
this.unit = "metric";
|
|
13
|
+
this.maxWidth = 100;
|
|
14
|
+
this._control = null;
|
|
15
|
+
this._mapEl = null;
|
|
16
|
+
}
|
|
17
|
+
static {
|
|
18
|
+
this.styles = [styles];
|
|
19
|
+
}
|
|
20
|
+
async connectedCallback() {
|
|
21
|
+
super.connectedCallback();
|
|
22
|
+
this._mapEl = findMapElement(this, "sigvelo-maplibre-map");
|
|
23
|
+
await this._mapEl?.whenMapReady(this, () => this._addControl());
|
|
24
|
+
}
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
super.disconnectedCallback();
|
|
27
|
+
if (this._control && this._mapEl?.map) this._mapEl.map.removeControl(this._control);
|
|
28
|
+
this._control = null;
|
|
29
|
+
}
|
|
30
|
+
_addControl() {
|
|
31
|
+
if (!this._mapEl?.map) return;
|
|
32
|
+
this._control = new maplibregl.ScaleControl({
|
|
33
|
+
maxWidth: this.maxWidth,
|
|
34
|
+
unit: this.unit
|
|
35
|
+
});
|
|
36
|
+
this._mapEl.map.addControl(this._control, this.position);
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
return html``;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
__decorate([property()], SigveloMaplibreScaleControl.prototype, "position", void 0);
|
|
43
|
+
__decorate([property()], SigveloMaplibreScaleControl.prototype, "unit", void 0);
|
|
44
|
+
__decorate([property({
|
|
45
|
+
attribute: "max-width",
|
|
46
|
+
type: Number
|
|
47
|
+
})], SigveloMaplibreScaleControl.prototype, "maxWidth", void 0);
|
|
48
|
+
SigveloMaplibreScaleControl = __decorate([customElement("sigvelo-maplibre-scale-control")], SigveloMaplibreScaleControl);
|
|
49
|
+
//#endregion
|
|
2
50
|
export { SigveloMaplibreScaleControl };
|
|
@@ -1,2 +1,77 @@
|
|
|
1
|
-
import { t as
|
|
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 { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
|
|
5
|
+
import styles from "@mcp-b/geo-support/styles/map-child.styles";
|
|
6
|
+
//#region src/components/tilelayer/tilelayer.ts
|
|
7
|
+
let SigveloMaplibreTilelayer = class SigveloMaplibreTilelayer extends LitElement {
|
|
8
|
+
constructor(..._args) {
|
|
9
|
+
super(..._args);
|
|
10
|
+
this.styleUrl = "";
|
|
11
|
+
this.url = "";
|
|
12
|
+
this.attribution = "";
|
|
13
|
+
this.opacity = 1;
|
|
14
|
+
this._rasterSourceId = "sigvelo-raster-source";
|
|
15
|
+
this._rasterLayerId = "sigvelo-raster-layer";
|
|
16
|
+
this._mapEl = null;
|
|
17
|
+
}
|
|
18
|
+
static {
|
|
19
|
+
this.styles = [styles];
|
|
20
|
+
}
|
|
21
|
+
async connectedCallback() {
|
|
22
|
+
super.connectedCallback();
|
|
23
|
+
this._mapEl = findMapElement(this, "sigvelo-maplibre-map");
|
|
24
|
+
await this._mapEl?.whenMapReady(this, () => this._applyTiles());
|
|
25
|
+
}
|
|
26
|
+
disconnectedCallback() {
|
|
27
|
+
super.disconnectedCallback();
|
|
28
|
+
this._removeRasterLayer();
|
|
29
|
+
}
|
|
30
|
+
_applyTiles() {
|
|
31
|
+
const map = this._mapEl?.map;
|
|
32
|
+
if (!map) return;
|
|
33
|
+
if (this.styleUrl) map.setStyle(this.styleUrl);
|
|
34
|
+
else if (this.url) this._addRasterLayer();
|
|
35
|
+
}
|
|
36
|
+
_addRasterLayer() {
|
|
37
|
+
const map = this._mapEl?.map;
|
|
38
|
+
if (!map || !this.url) return;
|
|
39
|
+
if (!map.isStyleLoaded()) return;
|
|
40
|
+
this._removeRasterLayer();
|
|
41
|
+
map.addSource(this._rasterSourceId, {
|
|
42
|
+
type: "raster",
|
|
43
|
+
tiles: [this.url],
|
|
44
|
+
tileSize: 256,
|
|
45
|
+
attribution: this.attribution || void 0
|
|
46
|
+
});
|
|
47
|
+
map.addLayer({
|
|
48
|
+
id: this._rasterLayerId,
|
|
49
|
+
type: "raster",
|
|
50
|
+
source: this._rasterSourceId,
|
|
51
|
+
paint: { "raster-opacity": this.opacity }
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
_removeRasterLayer() {
|
|
55
|
+
const map = this._mapEl?.map;
|
|
56
|
+
if (!map) return;
|
|
57
|
+
if (map.getLayer(this._rasterLayerId)) map.removeLayer(this._rasterLayerId);
|
|
58
|
+
if (map.getSource(this._rasterSourceId)) map.removeSource(this._rasterSourceId);
|
|
59
|
+
}
|
|
60
|
+
updated(changed) {
|
|
61
|
+
if (changed.has("styleUrl") || changed.has("url")) this._applyTiles();
|
|
62
|
+
if (changed.has("opacity") && this._mapEl?.map) {
|
|
63
|
+
const map = this._mapEl.map;
|
|
64
|
+
if (map.getLayer(this._rasterLayerId)) map.setPaintProperty(this._rasterLayerId, "raster-opacity", this.opacity);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
return html``;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
__decorate([property({ attribute: "style-url" })], SigveloMaplibreTilelayer.prototype, "styleUrl", void 0);
|
|
72
|
+
__decorate([property()], SigveloMaplibreTilelayer.prototype, "url", void 0);
|
|
73
|
+
__decorate([property()], SigveloMaplibreTilelayer.prototype, "attribution", void 0);
|
|
74
|
+
__decorate([property({ type: Number })], SigveloMaplibreTilelayer.prototype, "opacity", void 0);
|
|
75
|
+
SigveloMaplibreTilelayer = __decorate([customElement("sigvelo-maplibre-tilelayer")], SigveloMaplibreTilelayer);
|
|
76
|
+
//#endregion
|
|
2
77
|
export { SigveloMaplibreTilelayer };
|
|
@@ -217,7 +217,27 @@
|
|
|
217
217
|
"kind": "class",
|
|
218
218
|
"description": "A generic control container for a MapLibre map. Wraps arbitrary content\nand places it in one of MapLibre's four control corners, stacking properly\nwith navigation, attribution, and other controls.",
|
|
219
219
|
"name": "SigveloMaplibreControl",
|
|
220
|
+
"slots": [
|
|
221
|
+
{
|
|
222
|
+
"description": "Control content, retained in the control’s light DOM.",
|
|
223
|
+
"name": ""
|
|
224
|
+
}
|
|
225
|
+
],
|
|
220
226
|
"members": [
|
|
227
|
+
{
|
|
228
|
+
"kind": "method",
|
|
229
|
+
"name": "_removeControl",
|
|
230
|
+
"privacy": "private"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"kind": "field",
|
|
234
|
+
"name": "_stopPlacement",
|
|
235
|
+
"type": {
|
|
236
|
+
"text": "(() => void) | null"
|
|
237
|
+
},
|
|
238
|
+
"privacy": "private",
|
|
239
|
+
"default": "null"
|
|
240
|
+
},
|
|
221
241
|
{
|
|
222
242
|
"kind": "field",
|
|
223
243
|
"name": "position",
|
|
@@ -1260,7 +1280,7 @@
|
|
|
1260
1280
|
"kind": "field",
|
|
1261
1281
|
"name": "position",
|
|
1262
1282
|
"type": {
|
|
1263
|
-
"text": "
|
|
1283
|
+
"text": "ControlPosition"
|
|
1264
1284
|
},
|
|
1265
1285
|
"default": "\"bottom-left\"",
|
|
1266
1286
|
"description": "Position of the control on the map.",
|
|
@@ -1290,7 +1310,7 @@
|
|
|
1290
1310
|
{
|
|
1291
1311
|
"name": "position",
|
|
1292
1312
|
"type": {
|
|
1293
|
-
"text": "
|
|
1313
|
+
"text": "ControlPosition"
|
|
1294
1314
|
},
|
|
1295
1315
|
"default": "\"bottom-left\"",
|
|
1296
1316
|
"description": "Position of the control on the map.",
|
|
@@ -1562,7 +1582,7 @@
|
|
|
1562
1582
|
"package": {
|
|
1563
1583
|
"name": "@mcp-b/geo-maplibre",
|
|
1564
1584
|
"description": "MapLibre GL JS web components for Sigvelo, built with Lit.",
|
|
1565
|
-
"version": "0.
|
|
1585
|
+
"version": "0.3.0",
|
|
1566
1586
|
"license": "MIT"
|
|
1567
1587
|
}
|
|
1568
1588
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { SigveloMaplibreMap } from "./components/map/map.js";
|
|
2
|
+
import { SigveloMaplibreTilelayer } from "./components/tilelayer/tilelayer.js";
|
|
3
|
+
import { SigveloMaplibreMarker } from "./components/marker/marker.js";
|
|
4
|
+
import { SigveloMaplibrePopup } from "./components/popup/popup.js";
|
|
5
|
+
import { SigveloMaplibreGeojson } from "./components/geojson/geojson.js";
|
|
6
|
+
import { SigveloMaplibreCircle } from "./components/circle/circle.js";
|
|
7
|
+
import { SigveloMaplibrePolyline } from "./components/polyline/polyline.js";
|
|
8
|
+
import { SigveloMaplibrePolygon } from "./components/polygon/polygon.js";
|
|
9
|
+
import { SigveloMaplibreScaleControl } from "./components/scale-control/scale-control.js";
|
|
10
|
+
import { SigveloMaplibreLayer } from "./components/layer/layer.js";
|
|
11
|
+
import { SigveloMaplibreControl } from "./components/control/control.js";
|
|
12
12
|
export { SigveloMaplibreCircle, SigveloMaplibreControl, SigveloMaplibreGeojson, SigveloMaplibreLayer, SigveloMaplibreMap, SigveloMaplibreMarker, SigveloMaplibrePolygon, SigveloMaplibrePolyline, SigveloMaplibrePopup, SigveloMaplibreScaleControl, SigveloMaplibreTilelayer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-b/geo-maplibre",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MapLibre GL JS web components for Sigvelo, built with Lit.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"custom-elements",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@mcp-b/geo-support": "0.
|
|
38
|
-
"@mcp-b/wc-support": "0.
|
|
37
|
+
"@mcp-b/geo-support": "0.3.0",
|
|
38
|
+
"@mcp-b/wc-support": "0.3.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@custom-elements-manifest/analyzer": "^0.10.10",
|