@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
package/dist/circle-CFH3gDcY.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
|
-
import { LitElement, css, html } from "lit";
|
|
3
|
-
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
//#region src/components/circle/circle.styles.ts
|
|
5
|
-
var circle_styles_default = css`
|
|
6
|
-
:host {
|
|
7
|
-
display: none;
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/components/circle/circle.ts
|
|
12
|
-
let circleCounter = 0;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a GeoJSON polygon approximation of a circle on the map.
|
|
15
|
-
* @param lng - Center longitude
|
|
16
|
-
* @param lat - Center latitude
|
|
17
|
-
* @param radiusMeters - Radius in meters
|
|
18
|
-
* @param steps - Number of polygon vertices
|
|
19
|
-
*/
|
|
20
|
-
function createCirclePolygon(lng, lat, radiusMeters, steps = 64) {
|
|
21
|
-
const coords = [];
|
|
22
|
-
const earthRadius = 6371008.8;
|
|
23
|
-
const latRad = lat * Math.PI / 180;
|
|
24
|
-
for (let i = 0; i <= steps; i++) {
|
|
25
|
-
const angle = i * 2 * Math.PI / steps;
|
|
26
|
-
const dLat = radiusMeters / earthRadius * Math.cos(angle);
|
|
27
|
-
const dLng = radiusMeters / (earthRadius * Math.cos(latRad)) * Math.sin(angle);
|
|
28
|
-
coords.push([lng + dLng * 180 / Math.PI, lat + dLat * 180 / Math.PI]);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
type: "Feature",
|
|
32
|
-
geometry: {
|
|
33
|
-
type: "Polygon",
|
|
34
|
-
coordinates: [coords]
|
|
35
|
-
},
|
|
36
|
-
properties: {}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
let SigveloMaplibreCircle = class SigveloMaplibreCircle extends LitElement {
|
|
40
|
-
static {
|
|
41
|
-
this.styles = [circle_styles_default];
|
|
42
|
-
}
|
|
43
|
-
constructor() {
|
|
44
|
-
super();
|
|
45
|
-
this.latitude = 0;
|
|
46
|
-
this.longitude = 0;
|
|
47
|
-
this.radius = 100;
|
|
48
|
-
this.fillColor = "#3388ff";
|
|
49
|
-
this.fillOpacity = .2;
|
|
50
|
-
this.strokeColor = "#3388ff";
|
|
51
|
-
this.strokeWidth = 2;
|
|
52
|
-
this._mapEl = null;
|
|
53
|
-
const id = ++circleCounter;
|
|
54
|
-
this._sourceId = `sigvelo-circle-source-${id}`;
|
|
55
|
-
this._fillLayerId = `sigvelo-circle-fill-${id}`;
|
|
56
|
-
this._strokeLayerId = `sigvelo-circle-stroke-${id}`;
|
|
57
|
-
}
|
|
58
|
-
async connectedCallback() {
|
|
59
|
-
super.connectedCallback();
|
|
60
|
-
this._mapEl = this.closest("sigvelo-maplibre-map");
|
|
61
|
-
if (this._mapEl) {
|
|
62
|
-
await this._mapEl.mapReady;
|
|
63
|
-
this._addCircle();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
disconnectedCallback() {
|
|
67
|
-
super.disconnectedCallback();
|
|
68
|
-
this._removeCircle();
|
|
69
|
-
}
|
|
70
|
-
_buildGeoJSON() {
|
|
71
|
-
return createCirclePolygon(this.longitude, this.latitude, this.radius);
|
|
72
|
-
}
|
|
73
|
-
_addCircle() {
|
|
74
|
-
const map = this._mapEl?.map;
|
|
75
|
-
if (!map) return;
|
|
76
|
-
map.addSource(this._sourceId, {
|
|
77
|
-
type: "geojson",
|
|
78
|
-
data: this._buildGeoJSON()
|
|
79
|
-
});
|
|
80
|
-
map.addLayer({
|
|
81
|
-
id: this._fillLayerId,
|
|
82
|
-
type: "fill",
|
|
83
|
-
source: this._sourceId,
|
|
84
|
-
paint: {
|
|
85
|
-
"fill-color": this.fillColor,
|
|
86
|
-
"fill-opacity": this.fillOpacity
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
map.addLayer({
|
|
90
|
-
id: this._strokeLayerId,
|
|
91
|
-
type: "line",
|
|
92
|
-
source: this._sourceId,
|
|
93
|
-
paint: {
|
|
94
|
-
"line-color": this.strokeColor,
|
|
95
|
-
"line-width": this.strokeWidth
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
_removeCircle() {
|
|
100
|
-
const map = this._mapEl?.map;
|
|
101
|
-
if (!map) return;
|
|
102
|
-
for (const id of [this._fillLayerId, this._strokeLayerId]) if (map.getLayer(id)) map.removeLayer(id);
|
|
103
|
-
if (map.getSource(this._sourceId)) map.removeSource(this._sourceId);
|
|
104
|
-
}
|
|
105
|
-
_updateSource() {
|
|
106
|
-
const map = this._mapEl?.map;
|
|
107
|
-
if (!map) return;
|
|
108
|
-
const source = map.getSource(this._sourceId);
|
|
109
|
-
if (source) source.setData(this._buildGeoJSON());
|
|
110
|
-
}
|
|
111
|
-
updated(changed) {
|
|
112
|
-
if (!this._mapEl?.map) return;
|
|
113
|
-
if (changed.has("latitude") || changed.has("longitude") || changed.has("radius")) this._updateSource();
|
|
114
|
-
if (changed.has("fillColor") || changed.has("fillOpacity")) {
|
|
115
|
-
if (this._mapEl.map.getLayer(this._fillLayerId)) {
|
|
116
|
-
this._mapEl.map.setPaintProperty(this._fillLayerId, "fill-color", this.fillColor);
|
|
117
|
-
this._mapEl.map.setPaintProperty(this._fillLayerId, "fill-opacity", this.fillOpacity);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (changed.has("strokeColor") || changed.has("strokeWidth")) {
|
|
121
|
-
if (this._mapEl.map.getLayer(this._strokeLayerId)) {
|
|
122
|
-
this._mapEl.map.setPaintProperty(this._strokeLayerId, "line-color", this.strokeColor);
|
|
123
|
-
this._mapEl.map.setPaintProperty(this._strokeLayerId, "line-width", this.strokeWidth);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
render() {
|
|
128
|
-
return html``;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
__decorate([property({ type: Number })], SigveloMaplibreCircle.prototype, "latitude", void 0);
|
|
132
|
-
__decorate([property({ type: Number })], SigveloMaplibreCircle.prototype, "longitude", void 0);
|
|
133
|
-
__decorate([property({ type: Number })], SigveloMaplibreCircle.prototype, "radius", void 0);
|
|
134
|
-
__decorate([property({ attribute: "fill-color" })], SigveloMaplibreCircle.prototype, "fillColor", void 0);
|
|
135
|
-
__decorate([property({
|
|
136
|
-
attribute: "fill-opacity",
|
|
137
|
-
type: Number
|
|
138
|
-
})], SigveloMaplibreCircle.prototype, "fillOpacity", void 0);
|
|
139
|
-
__decorate([property({ attribute: "stroke-color" })], SigveloMaplibreCircle.prototype, "strokeColor", void 0);
|
|
140
|
-
__decorate([property({
|
|
141
|
-
attribute: "stroke-width",
|
|
142
|
-
type: Number
|
|
143
|
-
})], SigveloMaplibreCircle.prototype, "strokeWidth", void 0);
|
|
144
|
-
SigveloMaplibreCircle = __decorate([customElement("sigvelo-maplibre-circle")], SigveloMaplibreCircle);
|
|
145
|
-
//#endregion
|
|
146
|
-
export { SigveloMaplibreCircle as t };
|
package/dist/control-Bka68vGo.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
|
-
import { LitElement, css, html } from "lit";
|
|
3
|
-
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
//#region src/components/control/control.styles.ts
|
|
5
|
-
var control_styles_default = css`
|
|
6
|
-
:host {
|
|
7
|
-
display: none;
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/components/control/control.ts
|
|
12
|
-
let SigveloMaplibreControl = class SigveloMaplibreControl extends LitElement {
|
|
13
|
-
constructor(..._args) {
|
|
14
|
-
super(..._args);
|
|
15
|
-
this.position = "bottom-left";
|
|
16
|
-
this._control = null;
|
|
17
|
-
this._mapEl = null;
|
|
18
|
-
}
|
|
19
|
-
static {
|
|
20
|
-
this.styles = [control_styles_default];
|
|
21
|
-
}
|
|
22
|
-
async connectedCallback() {
|
|
23
|
-
super.connectedCallback();
|
|
24
|
-
this._mapEl = this.closest("sigvelo-maplibre-map");
|
|
25
|
-
if (this._mapEl) {
|
|
26
|
-
await this._mapEl.mapReady;
|
|
27
|
-
this._addControl();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
disconnectedCallback() {
|
|
31
|
-
super.disconnectedCallback();
|
|
32
|
-
if (this._control && this._mapEl?.map) this._mapEl.map.removeControl(this._control);
|
|
33
|
-
this._control = null;
|
|
34
|
-
}
|
|
35
|
-
/** @internal */
|
|
36
|
-
_addControl() {
|
|
37
|
-
const map = this._mapEl?.map;
|
|
38
|
-
if (!map) return;
|
|
39
|
-
const children = Array.from(this.children);
|
|
40
|
-
let container;
|
|
41
|
-
this._control = {
|
|
42
|
-
onAdd: () => {
|
|
43
|
-
container = document.createElement("div");
|
|
44
|
-
container.className = "maplibregl-ctrl sigvelo-maplibre-custom-control";
|
|
45
|
-
for (const child of children) container.appendChild(child);
|
|
46
|
-
return container;
|
|
47
|
-
},
|
|
48
|
-
onRemove: () => {
|
|
49
|
-
container?.remove();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
map.addControl(this._control, this.position);
|
|
53
|
-
}
|
|
54
|
-
render() {
|
|
55
|
-
return html` <slot></slot> `;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
__decorate([property()], SigveloMaplibreControl.prototype, "position", void 0);
|
|
59
|
-
SigveloMaplibreControl = __decorate([customElement("sigvelo-maplibre-control")], SigveloMaplibreControl);
|
|
60
|
-
//#endregion
|
|
61
|
-
export { SigveloMaplibreControl as t };
|
package/dist/geojson-BW9JQxtv.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
|
-
import { LitElement, css, html } from "lit";
|
|
3
|
-
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
import { SigveloFeatureClickEvent } from "@mcp-b/geo-support/events";
|
|
5
|
-
import { subscribeClassify } from "@mcp-b/geo-support/classification";
|
|
6
|
-
//#region src/components/geojson/geojson.styles.ts
|
|
7
|
-
var geojson_styles_default = css`
|
|
8
|
-
:host {
|
|
9
|
-
display: none;
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/components/geojson/geojson.ts
|
|
14
|
-
let sourceCounter = 0;
|
|
15
|
-
let SigveloMaplibreGeojson = class SigveloMaplibreGeojson extends LitElement {
|
|
16
|
-
static {
|
|
17
|
-
this.styles = [geojson_styles_default];
|
|
18
|
-
}
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
this.data = null;
|
|
22
|
-
this.styleFunction = null;
|
|
23
|
-
this.fillColor = "#3388ff";
|
|
24
|
-
this.fillOpacity = .2;
|
|
25
|
-
this.strokeColor = "#3388ff";
|
|
26
|
-
this.strokeWidth = 2;
|
|
27
|
-
this.circleRadius = 6;
|
|
28
|
-
this.interactive = true;
|
|
29
|
-
this.channel = "";
|
|
30
|
-
this._mapEl = null;
|
|
31
|
-
this._onStyleLoad = () => this._addSource();
|
|
32
|
-
this._unsubscribeChannel = null;
|
|
33
|
-
const id = ++sourceCounter;
|
|
34
|
-
this._sourceId = `sigvelo-geojson-source-${id}`;
|
|
35
|
-
this._fillLayerId = `sigvelo-geojson-fill-${id}`;
|
|
36
|
-
this._lineLayerId = `sigvelo-geojson-line-${id}`;
|
|
37
|
-
this._circleLayerId = `sigvelo-geojson-circle-${id}`;
|
|
38
|
-
}
|
|
39
|
-
async connectedCallback() {
|
|
40
|
-
super.connectedCallback();
|
|
41
|
-
this._subscribeChannel();
|
|
42
|
-
this._mapEl = this.closest("sigvelo-maplibre-map");
|
|
43
|
-
if (this._mapEl) {
|
|
44
|
-
await this._mapEl.mapReady;
|
|
45
|
-
const map = this._mapEl.map;
|
|
46
|
-
if (map) map.on("style.load", this._onStyleLoad);
|
|
47
|
-
this._addSource();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
disconnectedCallback() {
|
|
51
|
-
super.disconnectedCallback();
|
|
52
|
-
this._unsubscribeChannel?.();
|
|
53
|
-
this._unsubscribeChannel = null;
|
|
54
|
-
this._mapEl?.map?.off("style.load", this._onStyleLoad);
|
|
55
|
-
this._removeSource();
|
|
56
|
-
}
|
|
57
|
-
/** @internal */
|
|
58
|
-
_subscribeChannel() {
|
|
59
|
-
this._unsubscribeChannel?.();
|
|
60
|
-
if (!this.channel) return;
|
|
61
|
-
this._unsubscribeChannel = subscribeClassify(this.channel, (detail) => {
|
|
62
|
-
this.styleFunction = detail.styleFunction;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* When styleFunction is set, clone the data and inject computed style
|
|
67
|
-
* properties into each feature so MapLibre can use data-driven expressions.
|
|
68
|
-
* @internal
|
|
69
|
-
*/
|
|
70
|
-
_prepareData() {
|
|
71
|
-
if (!this.data) return null;
|
|
72
|
-
if (!this.styleFunction) return this.data;
|
|
73
|
-
const clone = JSON.parse(JSON.stringify(this.data));
|
|
74
|
-
const features = clone.type === "FeatureCollection" ? clone.features : [clone];
|
|
75
|
-
for (const feature of features) {
|
|
76
|
-
const s = this.styleFunction(feature);
|
|
77
|
-
if (s) {
|
|
78
|
-
feature.properties = feature.properties ?? {};
|
|
79
|
-
if (s.fillColor != null) feature.properties._sigvelo_fill_color = s.fillColor;
|
|
80
|
-
if (s.fillOpacity != null) feature.properties._sigvelo_fill_opacity = s.fillOpacity;
|
|
81
|
-
if (s.strokeColor != null) feature.properties._sigvelo_stroke_color = s.strokeColor;
|
|
82
|
-
if (s.strokeWidth != null) feature.properties._sigvelo_stroke_width = s.strokeWidth;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return clone;
|
|
86
|
-
}
|
|
87
|
-
_addSource() {
|
|
88
|
-
const map = this._mapEl?.map;
|
|
89
|
-
if (!map || !this.data) return;
|
|
90
|
-
if (!map.isStyleLoaded()) return;
|
|
91
|
-
this._removeSource();
|
|
92
|
-
const processedData = this._prepareData();
|
|
93
|
-
if (!processedData) return;
|
|
94
|
-
map.addSource(this._sourceId, {
|
|
95
|
-
type: "geojson",
|
|
96
|
-
data: processedData
|
|
97
|
-
});
|
|
98
|
-
const hasStyleFn = this.styleFunction != null;
|
|
99
|
-
map.addLayer({
|
|
100
|
-
id: this._fillLayerId,
|
|
101
|
-
type: "fill",
|
|
102
|
-
source: this._sourceId,
|
|
103
|
-
paint: {
|
|
104
|
-
"fill-color": hasStyleFn ? [
|
|
105
|
-
"coalesce",
|
|
106
|
-
["get", "_sigvelo_fill_color"],
|
|
107
|
-
this.fillColor
|
|
108
|
-
] : this.fillColor,
|
|
109
|
-
"fill-opacity": hasStyleFn ? [
|
|
110
|
-
"coalesce",
|
|
111
|
-
["get", "_sigvelo_fill_opacity"],
|
|
112
|
-
this.fillOpacity
|
|
113
|
-
] : this.fillOpacity
|
|
114
|
-
},
|
|
115
|
-
filter: [
|
|
116
|
-
"==",
|
|
117
|
-
"$type",
|
|
118
|
-
"Polygon"
|
|
119
|
-
]
|
|
120
|
-
});
|
|
121
|
-
map.addLayer({
|
|
122
|
-
id: this._lineLayerId,
|
|
123
|
-
type: "line",
|
|
124
|
-
source: this._sourceId,
|
|
125
|
-
paint: {
|
|
126
|
-
"line-color": hasStyleFn ? [
|
|
127
|
-
"coalesce",
|
|
128
|
-
["get", "_sigvelo_stroke_color"],
|
|
129
|
-
this.strokeColor
|
|
130
|
-
] : this.strokeColor,
|
|
131
|
-
"line-width": hasStyleFn ? [
|
|
132
|
-
"coalesce",
|
|
133
|
-
["get", "_sigvelo_stroke_width"],
|
|
134
|
-
this.strokeWidth
|
|
135
|
-
] : this.strokeWidth
|
|
136
|
-
},
|
|
137
|
-
filter: [
|
|
138
|
-
"any",
|
|
139
|
-
[
|
|
140
|
-
"==",
|
|
141
|
-
"$type",
|
|
142
|
-
"LineString"
|
|
143
|
-
],
|
|
144
|
-
[
|
|
145
|
-
"==",
|
|
146
|
-
"$type",
|
|
147
|
-
"Polygon"
|
|
148
|
-
]
|
|
149
|
-
]
|
|
150
|
-
});
|
|
151
|
-
map.addLayer({
|
|
152
|
-
id: this._circleLayerId,
|
|
153
|
-
type: "circle",
|
|
154
|
-
source: this._sourceId,
|
|
155
|
-
paint: {
|
|
156
|
-
"circle-color": hasStyleFn ? [
|
|
157
|
-
"coalesce",
|
|
158
|
-
["get", "_sigvelo_fill_color"],
|
|
159
|
-
this.fillColor
|
|
160
|
-
] : this.fillColor,
|
|
161
|
-
"circle-radius": this.circleRadius,
|
|
162
|
-
"circle-stroke-color": hasStyleFn ? [
|
|
163
|
-
"coalesce",
|
|
164
|
-
["get", "_sigvelo_stroke_color"],
|
|
165
|
-
this.strokeColor
|
|
166
|
-
] : this.strokeColor,
|
|
167
|
-
"circle-stroke-width": hasStyleFn ? [
|
|
168
|
-
"coalesce",
|
|
169
|
-
["get", "_sigvelo_stroke_width"],
|
|
170
|
-
this.strokeWidth
|
|
171
|
-
] : this.strokeWidth
|
|
172
|
-
},
|
|
173
|
-
filter: [
|
|
174
|
-
"==",
|
|
175
|
-
"$type",
|
|
176
|
-
"Point"
|
|
177
|
-
]
|
|
178
|
-
});
|
|
179
|
-
if (this.interactive) {
|
|
180
|
-
const layerIds = [
|
|
181
|
-
this._fillLayerId,
|
|
182
|
-
this._lineLayerId,
|
|
183
|
-
this._circleLayerId
|
|
184
|
-
];
|
|
185
|
-
for (const layerId of layerIds) map.on("click", layerId, (e) => {
|
|
186
|
-
const feature = e.features?.[0];
|
|
187
|
-
if (!feature) return;
|
|
188
|
-
this.dispatchEvent(new SigveloFeatureClickEvent({
|
|
189
|
-
type: "Feature",
|
|
190
|
-
geometry: feature.geometry,
|
|
191
|
-
properties: feature.properties ?? null,
|
|
192
|
-
id: feature.id
|
|
193
|
-
}, {
|
|
194
|
-
lat: e.lngLat.lat,
|
|
195
|
-
lng: e.lngLat.lng
|
|
196
|
-
}));
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
_removeSource() {
|
|
201
|
-
const map = this._mapEl?.map;
|
|
202
|
-
if (!map) return;
|
|
203
|
-
for (const id of [
|
|
204
|
-
this._fillLayerId,
|
|
205
|
-
this._lineLayerId,
|
|
206
|
-
this._circleLayerId
|
|
207
|
-
]) if (map.getLayer(id)) map.removeLayer(id);
|
|
208
|
-
if (map.getSource(this._sourceId)) map.removeSource(this._sourceId);
|
|
209
|
-
}
|
|
210
|
-
updated(changed) {
|
|
211
|
-
if (changed.has("data") || changed.has("styleFunction") || changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth") || changed.has("circleRadius")) {
|
|
212
|
-
this._removeSource();
|
|
213
|
-
this._addSource();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
render() {
|
|
217
|
-
return html``;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
__decorate([property({ attribute: false })], SigveloMaplibreGeojson.prototype, "data", void 0);
|
|
221
|
-
__decorate([property({ attribute: false })], SigveloMaplibreGeojson.prototype, "styleFunction", void 0);
|
|
222
|
-
__decorate([property({ attribute: "fill-color" })], SigveloMaplibreGeojson.prototype, "fillColor", void 0);
|
|
223
|
-
__decorate([property({
|
|
224
|
-
attribute: "fill-opacity",
|
|
225
|
-
type: Number
|
|
226
|
-
})], SigveloMaplibreGeojson.prototype, "fillOpacity", void 0);
|
|
227
|
-
__decorate([property({ attribute: "stroke-color" })], SigveloMaplibreGeojson.prototype, "strokeColor", void 0);
|
|
228
|
-
__decorate([property({
|
|
229
|
-
attribute: "stroke-width",
|
|
230
|
-
type: Number
|
|
231
|
-
})], SigveloMaplibreGeojson.prototype, "strokeWidth", void 0);
|
|
232
|
-
__decorate([property({
|
|
233
|
-
attribute: "circle-radius",
|
|
234
|
-
type: Number
|
|
235
|
-
})], SigveloMaplibreGeojson.prototype, "circleRadius", void 0);
|
|
236
|
-
__decorate([property({ type: Boolean })], SigveloMaplibreGeojson.prototype, "interactive", void 0);
|
|
237
|
-
__decorate([property()], SigveloMaplibreGeojson.prototype, "channel", void 0);
|
|
238
|
-
SigveloMaplibreGeojson = __decorate([customElement("sigvelo-maplibre-geojson")], SigveloMaplibreGeojson);
|
|
239
|
-
//#endregion
|
|
240
|
-
export { SigveloMaplibreGeojson as t };
|
package/dist/layer-COvBRP1h.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
|
-
import { LitElement, css, html } from "lit";
|
|
3
|
-
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
//#region src/components/layer/layer.styles.ts
|
|
5
|
-
var layer_styles_default = css`
|
|
6
|
-
:host {
|
|
7
|
-
display: none;
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/components/layer/layer.ts
|
|
12
|
-
let SigveloMaplibreLayer = class SigveloMaplibreLayer extends LitElement {
|
|
13
|
-
constructor(..._args) {
|
|
14
|
-
super(..._args);
|
|
15
|
-
this.spec = null;
|
|
16
|
-
this.beforeId = "";
|
|
17
|
-
this._mapEl = null;
|
|
18
|
-
this._addedLayerId = null;
|
|
19
|
-
}
|
|
20
|
-
static {
|
|
21
|
-
this.styles = [layer_styles_default];
|
|
22
|
-
}
|
|
23
|
-
async connectedCallback() {
|
|
24
|
-
super.connectedCallback();
|
|
25
|
-
this._mapEl = this.closest("sigvelo-maplibre-map");
|
|
26
|
-
if (this._mapEl) {
|
|
27
|
-
await this._mapEl.mapReady;
|
|
28
|
-
this._addLayer();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
disconnectedCallback() {
|
|
32
|
-
super.disconnectedCallback();
|
|
33
|
-
this._removeLayer();
|
|
34
|
-
}
|
|
35
|
-
_addLayer() {
|
|
36
|
-
const map = this._mapEl?.map;
|
|
37
|
-
if (!map || !this.spec) return;
|
|
38
|
-
map.addLayer(this.spec, this.beforeId || void 0);
|
|
39
|
-
this._addedLayerId = this.spec.id;
|
|
40
|
-
}
|
|
41
|
-
_removeLayer() {
|
|
42
|
-
const map = this._mapEl?.map;
|
|
43
|
-
if (!map || !this._addedLayerId) return;
|
|
44
|
-
if (map.getLayer(this._addedLayerId)) map.removeLayer(this._addedLayerId);
|
|
45
|
-
this._addedLayerId = null;
|
|
46
|
-
}
|
|
47
|
-
updated(changed) {
|
|
48
|
-
if (changed.has("spec")) {
|
|
49
|
-
this._removeLayer();
|
|
50
|
-
this._addLayer();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
render() {
|
|
54
|
-
return html``;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
__decorate([property({ attribute: false })], SigveloMaplibreLayer.prototype, "spec", void 0);
|
|
58
|
-
__decorate([property({ attribute: "before-id" })], SigveloMaplibreLayer.prototype, "beforeId", void 0);
|
|
59
|
-
SigveloMaplibreLayer = __decorate([customElement("sigvelo-maplibre-layer")], SigveloMaplibreLayer);
|
|
60
|
-
//#endregion
|
|
61
|
-
export { SigveloMaplibreLayer as t };
|
package/dist/map-CYqh-osb.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
|
-
import { css, unsafeCSS } from "lit";
|
|
3
|
-
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
import { GeoMapElement } from "@mcp-b/geo-support/base/geo-map-element";
|
|
5
|
-
import { SigveloMapClickEvent, SigveloMapLoadEvent, SigveloMapMoveEndEvent, SigveloMapMoveEvent, SigveloMapZoomEndEvent, SigveloMapZoomEvent } from "@mcp-b/geo-support/events";
|
|
6
|
-
import maplibregl from "maplibre-gl";
|
|
7
|
-
import maplibreCss from "maplibre-gl/dist/maplibre-gl.css?raw";
|
|
8
|
-
//#region src/components/map/map.styles.ts
|
|
9
|
-
var map_styles_default = css`
|
|
10
|
-
:host {
|
|
11
|
-
display: block;
|
|
12
|
-
position: relative;
|
|
13
|
-
min-height: 300px;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/components/map/map.ts
|
|
18
|
-
/** Empty style used when no tilelayer child provides a style-url. */
|
|
19
|
-
const EMPTY_STYLE = {
|
|
20
|
-
version: 8,
|
|
21
|
-
sources: {},
|
|
22
|
-
layers: []
|
|
23
|
-
};
|
|
24
|
-
let SigveloMaplibreMap = class SigveloMaplibreMap extends GeoMapElement {
|
|
25
|
-
constructor(..._args) {
|
|
26
|
-
super(..._args);
|
|
27
|
-
this.navControl = true;
|
|
28
|
-
this._map = null;
|
|
29
|
-
}
|
|
30
|
-
static {
|
|
31
|
-
this.styles = [
|
|
32
|
-
...GeoMapElement.styles,
|
|
33
|
-
unsafeCSS(maplibreCss),
|
|
34
|
-
map_styles_default
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
/** Access the underlying MapLibre map instance (after mapReady resolves). */
|
|
38
|
-
get map() {
|
|
39
|
-
return this._map;
|
|
40
|
-
}
|
|
41
|
-
createMap(container) {
|
|
42
|
-
this._map = new maplibregl.Map({
|
|
43
|
-
container,
|
|
44
|
-
style: EMPTY_STYLE,
|
|
45
|
-
center: [this.longitude, this.latitude],
|
|
46
|
-
zoom: this.zoom,
|
|
47
|
-
minZoom: this.minZoom,
|
|
48
|
-
maxZoom: this.maxZoom,
|
|
49
|
-
bearing: this.bearing,
|
|
50
|
-
pitch: this.pitch
|
|
51
|
-
});
|
|
52
|
-
if (this.navControl) this._map.addControl(new maplibregl.NavigationControl());
|
|
53
|
-
this._map.on("click", (e) => {
|
|
54
|
-
this.dispatchEvent(new SigveloMapClickEvent({
|
|
55
|
-
lat: e.lngLat.lat,
|
|
56
|
-
lng: e.lngLat.lng
|
|
57
|
-
}, e.originalEvent));
|
|
58
|
-
});
|
|
59
|
-
this._map.on("move", () => {
|
|
60
|
-
if (!this._map) return;
|
|
61
|
-
const center = this._map.getCenter();
|
|
62
|
-
this._suppressExternalUpdate = true;
|
|
63
|
-
this.latitude = center.lat;
|
|
64
|
-
this.longitude = center.lng;
|
|
65
|
-
this._suppressExternalUpdate = false;
|
|
66
|
-
this.dispatchEvent(new SigveloMapMoveEvent({
|
|
67
|
-
lat: center.lat,
|
|
68
|
-
lng: center.lng
|
|
69
|
-
}));
|
|
70
|
-
});
|
|
71
|
-
this._map.on("moveend", () => {
|
|
72
|
-
if (!this._map) return;
|
|
73
|
-
const center = this._map.getCenter();
|
|
74
|
-
this.dispatchEvent(new SigveloMapMoveEndEvent({
|
|
75
|
-
lat: center.lat,
|
|
76
|
-
lng: center.lng
|
|
77
|
-
}));
|
|
78
|
-
});
|
|
79
|
-
this._map.on("zoom", () => {
|
|
80
|
-
if (!this._map) return;
|
|
81
|
-
const zoom = this._map.getZoom();
|
|
82
|
-
this._suppressExternalUpdate = true;
|
|
83
|
-
this.zoom = zoom;
|
|
84
|
-
this._suppressExternalUpdate = false;
|
|
85
|
-
this.dispatchEvent(new SigveloMapZoomEvent(zoom));
|
|
86
|
-
});
|
|
87
|
-
this._map.on("zoomend", () => {
|
|
88
|
-
if (!this._map) return;
|
|
89
|
-
this.dispatchEvent(new SigveloMapZoomEndEvent(this._map.getZoom()));
|
|
90
|
-
});
|
|
91
|
-
this._map.on("load", () => {
|
|
92
|
-
this._resolveMapReady();
|
|
93
|
-
this.dispatchEvent(new SigveloMapLoadEvent());
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
destroyMap() {
|
|
97
|
-
this._map?.remove();
|
|
98
|
-
this._map = null;
|
|
99
|
-
}
|
|
100
|
-
updateView(changed) {
|
|
101
|
-
if (!this._map) return;
|
|
102
|
-
if (changed.has("latitude") || changed.has("longitude")) this._map.setCenter([this.longitude, this.latitude]);
|
|
103
|
-
if (changed.has("zoom")) this._map.setZoom(this.zoom);
|
|
104
|
-
if (changed.has("bearing")) this._map.setBearing(this.bearing);
|
|
105
|
-
if (changed.has("pitch")) this._map.setPitch(this.pitch);
|
|
106
|
-
if (changed.has("minZoom")) this._map.setMinZoom(this.minZoom);
|
|
107
|
-
if (changed.has("maxZoom")) this._map.setMaxZoom(this.maxZoom);
|
|
108
|
-
}
|
|
109
|
-
invalidateSize() {
|
|
110
|
-
this._map?.resize();
|
|
111
|
-
}
|
|
112
|
-
flyTo(options) {
|
|
113
|
-
this._map?.flyTo({
|
|
114
|
-
center: [options.center.lng, options.center.lat],
|
|
115
|
-
zoom: options.zoom,
|
|
116
|
-
bearing: options.bearing,
|
|
117
|
-
pitch: options.pitch,
|
|
118
|
-
duration: options.duration
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
fitBounds(options) {
|
|
122
|
-
this._map?.fitBounds([[options.bounds.west, options.bounds.south], [options.bounds.east, options.bounds.north]], {
|
|
123
|
-
padding: options.padding,
|
|
124
|
-
maxZoom: options.maxZoom,
|
|
125
|
-
duration: options.duration
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
__decorate([property({
|
|
130
|
-
attribute: "nav-control",
|
|
131
|
-
type: Boolean
|
|
132
|
-
})], SigveloMaplibreMap.prototype, "navControl", void 0);
|
|
133
|
-
SigveloMaplibreMap = __decorate([customElement("sigvelo-maplibre-map")], SigveloMaplibreMap);
|
|
134
|
-
//#endregion
|
|
135
|
-
export { SigveloMaplibreMap as t };
|