@mcp-b/geo-openlayers 0.2.22 → 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.d.ts +0 -2
- package/dist/components/circle/circle.js +90 -1
- package/dist/components/control/control.d.ts +7 -2
- package/dist/components/control/control.js +65 -1
- package/dist/components/geojson/geojson.d.ts +6 -3
- package/dist/components/geojson/geojson.js +179 -1
- package/dist/components/map/map.js +133 -1
- package/dist/components/marker/marker.js +96 -1
- package/dist/components/overlay/overlay.js +56 -1
- package/dist/components/polygon/polygon.d.ts +0 -2
- package/dist/components/polygon/polygon.js +93 -1
- package/dist/components/polyline/polyline.d.ts +0 -2
- package/dist/components/polyline/polyline.js +77 -1
- package/dist/components/popup/popup.js +23 -1
- package/dist/components/scale-control/scale-control.js +48 -1
- package/dist/components/tilelayer/tilelayer.js +64 -1
- package/dist/docs/custom-elements.json +64 -1
- package/dist/hex-to-rgba.d.ts +13 -0
- package/dist/hex-to-rgba.js +15 -0
- package/dist/index.js +11 -11
- package/package.json +3 -3
- package/dist/circle-BiLEqiGC.js +0 -102
- package/dist/control-CTiiOtzM.js +0 -59
- package/dist/geojson-BU-tOeyz.js +0 -184
- package/dist/map-eGQh7n8O.js +0 -146
- package/dist/marker-DEG_oTfJ.js +0 -124
- package/dist/overlay-BFXjnhLj.js +0 -65
- package/dist/polygon-BaKBzEHK.js +0 -105
- package/dist/polyline-DXXHbwfm.js +0 -89
- package/dist/popup-CpiCysPO.js +0 -30
- package/dist/scale-control-zMLnp2Rt.js +0 -57
- package/dist/tilelayer-BAC1OCHe.js +0 -73
|
@@ -32,8 +32,6 @@ declare class SigveloOlCircle extends LitElement {
|
|
|
32
32
|
connectedCallback(): Promise<void>;
|
|
33
33
|
disconnectedCallback(): void;
|
|
34
34
|
/** @internal */
|
|
35
|
-
private _hexToRgba;
|
|
36
|
-
/** @internal */
|
|
37
35
|
private _addCircle;
|
|
38
36
|
protected updated(changed: PropertyValues): void;
|
|
39
37
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -1,2 +1,91 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hexToRgba } from "../../hex-to-rgba.js";
|
|
2
|
+
import { t as __decorate } from "../../decorate-DcF3lt7P.js";
|
|
3
|
+
import { LitElement, html } from "lit";
|
|
4
|
+
import { customElement, property } from "lit/decorators.js";
|
|
5
|
+
import { fromLonLat } from "ol/proj.js";
|
|
6
|
+
import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
|
|
7
|
+
import styles from "@mcp-b/geo-support/styles/map-child.styles";
|
|
8
|
+
import VectorLayer from "ol/layer/Vector.js";
|
|
9
|
+
import VectorSource from "ol/source/Vector.js";
|
|
10
|
+
import { Fill, Stroke, Style } from "ol/style.js";
|
|
11
|
+
import Feature from "ol/Feature.js";
|
|
12
|
+
import Circle$1 from "ol/geom/Circle.js";
|
|
13
|
+
//#region src/components/circle/circle.ts
|
|
14
|
+
let SigveloOlCircle = class SigveloOlCircle extends LitElement {
|
|
15
|
+
constructor(..._args) {
|
|
16
|
+
super(..._args);
|
|
17
|
+
this.latitude = 0;
|
|
18
|
+
this.longitude = 0;
|
|
19
|
+
this.radius = 100;
|
|
20
|
+
this.fillColor = "#3388ff";
|
|
21
|
+
this.fillOpacity = .2;
|
|
22
|
+
this.strokeColor = "#3388ff";
|
|
23
|
+
this.strokeWidth = 2;
|
|
24
|
+
this._layer = null;
|
|
25
|
+
this._feature = null;
|
|
26
|
+
this._mapEl = null;
|
|
27
|
+
}
|
|
28
|
+
static {
|
|
29
|
+
this.styles = [styles];
|
|
30
|
+
}
|
|
31
|
+
async connectedCallback() {
|
|
32
|
+
super.connectedCallback();
|
|
33
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
34
|
+
await this._mapEl?.whenMapReady(this, () => this._addCircle());
|
|
35
|
+
}
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
super.disconnectedCallback();
|
|
38
|
+
if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
|
|
39
|
+
this._layer = null;
|
|
40
|
+
this._feature = null;
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
_addCircle() {
|
|
44
|
+
if (!this._mapEl?.map) return;
|
|
45
|
+
const geometry = new Circle$1(fromLonLat([this.longitude, this.latitude]), this.radius);
|
|
46
|
+
this._feature = new Feature({ geometry });
|
|
47
|
+
const style = new Style({
|
|
48
|
+
fill: new Fill({ color: hexToRgba(this.fillColor, this.fillOpacity) }),
|
|
49
|
+
stroke: new Stroke({
|
|
50
|
+
color: this.strokeColor,
|
|
51
|
+
width: this.strokeWidth
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
this._layer = new VectorLayer({
|
|
55
|
+
source: new VectorSource({ features: [this._feature] }),
|
|
56
|
+
style
|
|
57
|
+
});
|
|
58
|
+
this._mapEl.map.addLayer(this._layer);
|
|
59
|
+
}
|
|
60
|
+
updated(changed) {
|
|
61
|
+
if (!this._feature || !this._layer) return;
|
|
62
|
+
if (changed.has("latitude") || changed.has("longitude")) this._feature.getGeometry().setCenter(fromLonLat([this.longitude, this.latitude]));
|
|
63
|
+
if (changed.has("radius")) this._feature.getGeometry().setRadius(this.radius);
|
|
64
|
+
if (changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth")) this._layer.setStyle(new Style({
|
|
65
|
+
fill: new Fill({ color: hexToRgba(this.fillColor, this.fillOpacity) }),
|
|
66
|
+
stroke: new Stroke({
|
|
67
|
+
color: this.strokeColor,
|
|
68
|
+
width: this.strokeWidth
|
|
69
|
+
})
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
return html``;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
__decorate([property({ type: Number })], SigveloOlCircle.prototype, "latitude", void 0);
|
|
77
|
+
__decorate([property({ type: Number })], SigveloOlCircle.prototype, "longitude", void 0);
|
|
78
|
+
__decorate([property({ type: Number })], SigveloOlCircle.prototype, "radius", void 0);
|
|
79
|
+
__decorate([property({ attribute: "fill-color" })], SigveloOlCircle.prototype, "fillColor", void 0);
|
|
80
|
+
__decorate([property({
|
|
81
|
+
attribute: "fill-opacity",
|
|
82
|
+
type: Number
|
|
83
|
+
})], SigveloOlCircle.prototype, "fillOpacity", void 0);
|
|
84
|
+
__decorate([property({ attribute: "stroke-color" })], SigveloOlCircle.prototype, "strokeColor", void 0);
|
|
85
|
+
__decorate([property({
|
|
86
|
+
attribute: "stroke-width",
|
|
87
|
+
type: Number
|
|
88
|
+
})], SigveloOlCircle.prototype, "strokeWidth", void 0);
|
|
89
|
+
SigveloOlCircle = __decorate([customElement("sigvelo-ol-circle")], SigveloOlCircle);
|
|
90
|
+
//#endregion
|
|
2
91
|
export { SigveloOlCircle };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
1
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
|
+
import { ControlPosition } from "@mcp-b/geo-support/types";
|
|
2
3
|
|
|
3
4
|
//#region src/components/control/control.d.ts
|
|
4
|
-
type ControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
5
5
|
/**
|
|
6
6
|
* A generic control container for an OpenLayers map. Wraps arbitrary content
|
|
7
7
|
* and adds it as an OL control, positioned in a map corner.
|
|
8
8
|
*
|
|
9
|
+
* @slot - Control content, retained in the control’s light DOM.
|
|
10
|
+
*
|
|
9
11
|
* @tag sigvelo-ol-control
|
|
10
12
|
*
|
|
11
13
|
* @example
|
|
@@ -22,12 +24,15 @@ declare class SigveloOlControl extends LitElement {
|
|
|
22
24
|
static styles: import("lit").CSSResult[];
|
|
23
25
|
/** Position of the control on the map. */
|
|
24
26
|
position: ControlPosition;
|
|
27
|
+
private _stopPlacement;
|
|
25
28
|
/** @internal */
|
|
26
29
|
private _control;
|
|
27
30
|
/** @internal */
|
|
28
31
|
private _mapEl;
|
|
29
32
|
connectedCallback(): Promise<void>;
|
|
30
33
|
disconnectedCallback(): void;
|
|
34
|
+
private _removeControl;
|
|
35
|
+
protected updated(changed: PropertyValues): void;
|
|
31
36
|
/** @internal */
|
|
32
37
|
private _addControl;
|
|
33
38
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -1,2 +1,66 @@
|
|
|
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 Control from "ol/control/Control.js";
|
|
6
|
+
import { placeControl } from "@mcp-b/geo-support/base/control-placement";
|
|
7
|
+
import styles from "@mcp-b/geo-support/styles/control.styles";
|
|
8
|
+
//#region src/components/control/control.ts
|
|
9
|
+
const POSITION_CSS = {
|
|
10
|
+
"top-left": "top: 0.5em; left: 0.5em;",
|
|
11
|
+
"top-right": "top: 0.5em; right: 0.5em;",
|
|
12
|
+
"bottom-left": "bottom: 0.5em; left: 0.5em;",
|
|
13
|
+
"bottom-right": "bottom: 0.5em; right: 0.5em;"
|
|
14
|
+
};
|
|
15
|
+
let SigveloOlControl = class SigveloOlControl extends LitElement {
|
|
16
|
+
constructor(..._args) {
|
|
17
|
+
super(..._args);
|
|
18
|
+
this.position = "bottom-left";
|
|
19
|
+
this._stopPlacement = null;
|
|
20
|
+
this._control = null;
|
|
21
|
+
this._mapEl = null;
|
|
22
|
+
}
|
|
23
|
+
static {
|
|
24
|
+
this.styles = [styles];
|
|
25
|
+
}
|
|
26
|
+
async connectedCallback() {
|
|
27
|
+
super.connectedCallback();
|
|
28
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
29
|
+
await this._mapEl?.whenMapReady(this, () => {
|
|
30
|
+
if (!this._control) this._addControl();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
super.disconnectedCallback();
|
|
35
|
+
this._removeControl();
|
|
36
|
+
}
|
|
37
|
+
_removeControl() {
|
|
38
|
+
this._stopPlacement?.();
|
|
39
|
+
this._stopPlacement = null;
|
|
40
|
+
if (this._control && this._mapEl?.map) this._mapEl.map.removeControl(this._control);
|
|
41
|
+
this._control = null;
|
|
42
|
+
}
|
|
43
|
+
updated(changed) {
|
|
44
|
+
if (changed.has("position") && this._control) {
|
|
45
|
+
this._removeControl();
|
|
46
|
+
this._addControl();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** @internal */
|
|
50
|
+
_addControl() {
|
|
51
|
+
if (!this._mapEl?.map) return;
|
|
52
|
+
const container = document.createElement("div");
|
|
53
|
+
container.className = "ol-control sigvelo-ol-custom-control";
|
|
54
|
+
container.style.cssText = `position: absolute; ${POSITION_CSS[this.position]} pointer-events: auto;`;
|
|
55
|
+
this._control = new Control({ element: container });
|
|
56
|
+
this._mapEl.map.addControl(this._control);
|
|
57
|
+
this._stopPlacement = placeControl(this, container, this._mapEl);
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return html` <slot></slot> `;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
__decorate([property()], SigveloOlControl.prototype, "position", void 0);
|
|
64
|
+
SigveloOlControl = __decorate([customElement("sigvelo-ol-control")], SigveloOlControl);
|
|
65
|
+
//#endregion
|
|
2
66
|
export { SigveloOlControl };
|
|
@@ -44,7 +44,12 @@ declare class SigveloOlGeojson extends LitElement {
|
|
|
44
44
|
disconnectedCallback(): void;
|
|
45
45
|
/** @internal */
|
|
46
46
|
private _subscribeChannel;
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* @internal Convert an OL feature to a GeoJsonFeature for the styleFunction.
|
|
49
|
+
*
|
|
50
|
+
* A style function is handed a `FeatureLike`, not a `Feature`: a vector tile source styles `RenderFeature`s, which
|
|
51
|
+
* carry properties and an id but are not full features. Both shapes answer everything read here.
|
|
52
|
+
*/
|
|
48
53
|
private _toGeoJsonFeature;
|
|
49
54
|
/** @internal */
|
|
50
55
|
private _addLayer;
|
|
@@ -52,8 +57,6 @@ declare class SigveloOlGeojson extends LitElement {
|
|
|
52
57
|
private _removeLayer;
|
|
53
58
|
/** @internal */
|
|
54
59
|
private _bindClickHandler;
|
|
55
|
-
/** @internal */
|
|
56
|
-
private _hexToRgba;
|
|
57
60
|
protected updated(changed: PropertyValues): void;
|
|
58
61
|
render(): import("lit-html").TemplateResult<1>;
|
|
59
62
|
}
|
|
@@ -1,2 +1,180 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hexToRgba } from "../../hex-to-rgba.js";
|
|
2
|
+
import { t as __decorate } from "../../decorate-DcF3lt7P.js";
|
|
3
|
+
import { LitElement, html } from "lit";
|
|
4
|
+
import { customElement, property } from "lit/decorators.js";
|
|
5
|
+
import { SigveloFeatureClickEvent } from "@mcp-b/geo-support/events";
|
|
6
|
+
import { toLonLat } from "ol/proj.js";
|
|
7
|
+
import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
|
|
8
|
+
import styles from "@mcp-b/geo-support/styles/map-child.styles";
|
|
9
|
+
import { subscribeClassify } from "@mcp-b/geo-support/classification";
|
|
10
|
+
import VectorLayer from "ol/layer/Vector.js";
|
|
11
|
+
import VectorSource from "ol/source/Vector.js";
|
|
12
|
+
import GeoJSON from "ol/format/GeoJSON.js";
|
|
13
|
+
import { Circle, Fill, Stroke, Style } from "ol/style.js";
|
|
14
|
+
//#region src/components/geojson/geojson.ts
|
|
15
|
+
let SigveloOlGeojson = class SigveloOlGeojson extends LitElement {
|
|
16
|
+
constructor(..._args) {
|
|
17
|
+
super(..._args);
|
|
18
|
+
this.data = null;
|
|
19
|
+
this.styleFunction = null;
|
|
20
|
+
this.fillColor = "#3388ff";
|
|
21
|
+
this.fillOpacity = .2;
|
|
22
|
+
this.strokeColor = "#3388ff";
|
|
23
|
+
this.strokeWidth = 2;
|
|
24
|
+
this.circleRadius = 6;
|
|
25
|
+
this.interactive = true;
|
|
26
|
+
this.channel = "";
|
|
27
|
+
this._layer = null;
|
|
28
|
+
this._mapEl = null;
|
|
29
|
+
this._unsubscribeChannel = null;
|
|
30
|
+
}
|
|
31
|
+
static {
|
|
32
|
+
this.styles = [styles];
|
|
33
|
+
}
|
|
34
|
+
async connectedCallback() {
|
|
35
|
+
super.connectedCallback();
|
|
36
|
+
this._subscribeChannel();
|
|
37
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
38
|
+
await this._mapEl?.whenMapReady(this, () => {
|
|
39
|
+
this._addLayer();
|
|
40
|
+
this._bindClickHandler();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
super.disconnectedCallback();
|
|
45
|
+
this._unsubscribeChannel?.();
|
|
46
|
+
this._unsubscribeChannel = null;
|
|
47
|
+
this._removeLayer();
|
|
48
|
+
}
|
|
49
|
+
/** @internal */
|
|
50
|
+
_subscribeChannel() {
|
|
51
|
+
this._unsubscribeChannel?.();
|
|
52
|
+
if (!this.channel) return;
|
|
53
|
+
this._unsubscribeChannel = subscribeClassify(this.channel, (detail) => {
|
|
54
|
+
this.styleFunction = detail.styleFunction;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @internal Convert an OL feature to a GeoJsonFeature for the styleFunction.
|
|
59
|
+
*
|
|
60
|
+
* A style function is handed a `FeatureLike`, not a `Feature`: a vector tile source styles `RenderFeature`s, which
|
|
61
|
+
* carry properties and an id but are not full features. Both shapes answer everything read here.
|
|
62
|
+
*/
|
|
63
|
+
_toGeoJsonFeature(olFeature) {
|
|
64
|
+
const { geometry: _g, ...rest } = olFeature.getProperties();
|
|
65
|
+
return {
|
|
66
|
+
type: "Feature",
|
|
67
|
+
geometry: {
|
|
68
|
+
type: olFeature.getGeometry()?.getType() ?? "Point",
|
|
69
|
+
coordinates: null
|
|
70
|
+
},
|
|
71
|
+
properties: rest,
|
|
72
|
+
id: olFeature.getId()
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** @internal */
|
|
76
|
+
_addLayer() {
|
|
77
|
+
if (!this._mapEl?.map || !this.data) return;
|
|
78
|
+
const source = new VectorSource({ features: new GeoJSON().readFeatures(this.data, { featureProjection: "EPSG:3857" }) });
|
|
79
|
+
const defaultStyle = new Style({
|
|
80
|
+
fill: new Fill({ color: hexToRgba(this.fillColor, this.fillOpacity) }),
|
|
81
|
+
stroke: new Stroke({
|
|
82
|
+
color: this.strokeColor,
|
|
83
|
+
width: this.strokeWidth
|
|
84
|
+
}),
|
|
85
|
+
image: new Circle({
|
|
86
|
+
radius: this.circleRadius,
|
|
87
|
+
fill: new Fill({ color: this.fillColor }),
|
|
88
|
+
stroke: new Stroke({
|
|
89
|
+
color: this.strokeColor,
|
|
90
|
+
width: this.strokeWidth
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
const styleFn = this.styleFunction;
|
|
95
|
+
const olStyleFn = styleFn ? (olFeature) => {
|
|
96
|
+
const s = styleFn(this._toGeoJsonFeature(olFeature));
|
|
97
|
+
if (!s) return defaultStyle;
|
|
98
|
+
return new Style({
|
|
99
|
+
fill: new Fill({ color: hexToRgba(s.fillColor ?? this.fillColor, s.fillOpacity ?? this.fillOpacity) }),
|
|
100
|
+
stroke: new Stroke({
|
|
101
|
+
color: s.strokeColor ?? this.strokeColor,
|
|
102
|
+
width: s.strokeWidth ?? this.strokeWidth
|
|
103
|
+
}),
|
|
104
|
+
image: new Circle({
|
|
105
|
+
radius: this.circleRadius,
|
|
106
|
+
fill: new Fill({ color: hexToRgba(s.fillColor ?? this.fillColor, s.fillOpacity ?? this.fillOpacity) }),
|
|
107
|
+
stroke: new Stroke({
|
|
108
|
+
color: s.strokeColor ?? this.strokeColor,
|
|
109
|
+
width: s.strokeWidth ?? this.strokeWidth
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
} : defaultStyle;
|
|
114
|
+
this._layer = new VectorLayer({
|
|
115
|
+
source,
|
|
116
|
+
style: olStyleFn
|
|
117
|
+
});
|
|
118
|
+
this._mapEl.map.addLayer(this._layer);
|
|
119
|
+
}
|
|
120
|
+
/** @internal */
|
|
121
|
+
_removeLayer() {
|
|
122
|
+
if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
|
|
123
|
+
this._layer = null;
|
|
124
|
+
}
|
|
125
|
+
/** @internal */
|
|
126
|
+
_bindClickHandler() {
|
|
127
|
+
if (!this.interactive || !this._mapEl?.map) return;
|
|
128
|
+
this._mapEl.map.on("click", (e) => {
|
|
129
|
+
if (!this._mapEl?.map) return;
|
|
130
|
+
this._mapEl.map.forEachFeatureAtPixel(e.pixel, (feature) => {
|
|
131
|
+
const geom = feature.getGeometry();
|
|
132
|
+
if (!geom) return;
|
|
133
|
+
const [lng, lat] = toLonLat(e.coordinate);
|
|
134
|
+
const { geometry: _geom, ...rest } = feature.getProperties();
|
|
135
|
+
this.dispatchEvent(new SigveloFeatureClickEvent({
|
|
136
|
+
type: "Feature",
|
|
137
|
+
geometry: {
|
|
138
|
+
type: geom.getType(),
|
|
139
|
+
coordinates: null
|
|
140
|
+
},
|
|
141
|
+
properties: rest,
|
|
142
|
+
id: feature.getId()
|
|
143
|
+
}, {
|
|
144
|
+
lat,
|
|
145
|
+
lng
|
|
146
|
+
}));
|
|
147
|
+
}, { layerFilter: (l) => l === this._layer });
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
updated(changed) {
|
|
151
|
+
if (changed.has("data") || changed.has("styleFunction") || changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth") || changed.has("circleRadius")) {
|
|
152
|
+
this._removeLayer();
|
|
153
|
+
this._addLayer();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
render() {
|
|
157
|
+
return html``;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
__decorate([property({ attribute: false })], SigveloOlGeojson.prototype, "data", void 0);
|
|
161
|
+
__decorate([property({ attribute: false })], SigveloOlGeojson.prototype, "styleFunction", void 0);
|
|
162
|
+
__decorate([property({ attribute: "fill-color" })], SigveloOlGeojson.prototype, "fillColor", void 0);
|
|
163
|
+
__decorate([property({
|
|
164
|
+
attribute: "fill-opacity",
|
|
165
|
+
type: Number
|
|
166
|
+
})], SigveloOlGeojson.prototype, "fillOpacity", void 0);
|
|
167
|
+
__decorate([property({ attribute: "stroke-color" })], SigveloOlGeojson.prototype, "strokeColor", void 0);
|
|
168
|
+
__decorate([property({
|
|
169
|
+
attribute: "stroke-width",
|
|
170
|
+
type: Number
|
|
171
|
+
})], SigveloOlGeojson.prototype, "strokeWidth", void 0);
|
|
172
|
+
__decorate([property({
|
|
173
|
+
attribute: "circle-radius",
|
|
174
|
+
type: Number
|
|
175
|
+
})], SigveloOlGeojson.prototype, "circleRadius", void 0);
|
|
176
|
+
__decorate([property({ type: Boolean })], SigveloOlGeojson.prototype, "interactive", void 0);
|
|
177
|
+
__decorate([property()], SigveloOlGeojson.prototype, "channel", void 0);
|
|
178
|
+
SigveloOlGeojson = __decorate([customElement("sigvelo-ol-geojson")], SigveloOlGeojson);
|
|
179
|
+
//#endregion
|
|
2
180
|
export { SigveloOlGeojson };
|
|
@@ -1,2 +1,134 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as __decorate } from "../../decorate-DcF3lt7P.js";
|
|
2
|
+
import { unsafeCSS } from "lit";
|
|
3
|
+
import { customElement } 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 OlMap from "ol/Map.js";
|
|
7
|
+
import View from "ol/View.js";
|
|
8
|
+
import { fromLonLat, toLonLat } from "ol/proj.js";
|
|
9
|
+
import olCss from "ol/ol.css?raw";
|
|
10
|
+
//#region src/components/map/map.ts
|
|
11
|
+
let SigveloOlMap = class SigveloOlMap extends GeoMapElement {
|
|
12
|
+
constructor(..._args) {
|
|
13
|
+
super(..._args);
|
|
14
|
+
this._map = null;
|
|
15
|
+
this._view = null;
|
|
16
|
+
}
|
|
17
|
+
static {
|
|
18
|
+
this.styles = [...GeoMapElement.styles, unsafeCSS(olCss)];
|
|
19
|
+
}
|
|
20
|
+
/** Access the underlying OpenLayers map instance (after mapReady resolves). */
|
|
21
|
+
get map() {
|
|
22
|
+
return this._map;
|
|
23
|
+
}
|
|
24
|
+
/** Access the underlying OpenLayers view instance. */
|
|
25
|
+
get view() {
|
|
26
|
+
return this._view;
|
|
27
|
+
}
|
|
28
|
+
createMap(container) {
|
|
29
|
+
this._view = new View({
|
|
30
|
+
center: fromLonLat([this.longitude, this.latitude]),
|
|
31
|
+
zoom: this.zoom,
|
|
32
|
+
minZoom: this.minZoom,
|
|
33
|
+
maxZoom: this.maxZoom,
|
|
34
|
+
rotation: this.bearing * Math.PI / 180
|
|
35
|
+
});
|
|
36
|
+
this._map = new OlMap({
|
|
37
|
+
target: container,
|
|
38
|
+
view: this._view
|
|
39
|
+
});
|
|
40
|
+
this._map.on("click", (e) => {
|
|
41
|
+
if (!(e.originalEvent instanceof MouseEvent)) return;
|
|
42
|
+
const [lng, lat] = toLonLat(e.coordinate);
|
|
43
|
+
this.dispatchEvent(new SigveloMapClickEvent({
|
|
44
|
+
lat,
|
|
45
|
+
lng
|
|
46
|
+
}, e.originalEvent));
|
|
47
|
+
});
|
|
48
|
+
this._view.on("change:center", () => {
|
|
49
|
+
if (!this._view) return;
|
|
50
|
+
const center = this._view.getCenter();
|
|
51
|
+
if (!center) return;
|
|
52
|
+
const [lng, lat] = toLonLat(center);
|
|
53
|
+
this._suppressExternalUpdate = true;
|
|
54
|
+
this.latitude = lat;
|
|
55
|
+
this.longitude = lng;
|
|
56
|
+
this._suppressExternalUpdate = false;
|
|
57
|
+
this.dispatchEvent(new SigveloMapMoveEvent({
|
|
58
|
+
lat,
|
|
59
|
+
lng
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
62
|
+
this._view.on("change:resolution", () => {
|
|
63
|
+
if (!this._view) return;
|
|
64
|
+
const zoom = this._view.getZoom() ?? this.zoom;
|
|
65
|
+
this._suppressExternalUpdate = true;
|
|
66
|
+
this.zoom = zoom;
|
|
67
|
+
this._suppressExternalUpdate = false;
|
|
68
|
+
this.dispatchEvent(new SigveloMapZoomEvent(zoom));
|
|
69
|
+
});
|
|
70
|
+
this._map.on("moveend", () => {
|
|
71
|
+
if (!this._view) return;
|
|
72
|
+
const center = this._view.getCenter();
|
|
73
|
+
if (!center) return;
|
|
74
|
+
const [lng, lat] = toLonLat(center);
|
|
75
|
+
const zoom = this._view.getZoom() ?? this.zoom;
|
|
76
|
+
this.dispatchEvent(new SigveloMapMoveEndEvent({
|
|
77
|
+
lat,
|
|
78
|
+
lng
|
|
79
|
+
}));
|
|
80
|
+
this.dispatchEvent(new SigveloMapZoomEndEvent(zoom));
|
|
81
|
+
});
|
|
82
|
+
this._map.once("rendercomplete", () => {
|
|
83
|
+
this._resolveMapReady();
|
|
84
|
+
this.dispatchEvent(new SigveloMapLoadEvent());
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
destroyMap() {
|
|
88
|
+
this._map?.dispose();
|
|
89
|
+
this._map = null;
|
|
90
|
+
this._view = null;
|
|
91
|
+
}
|
|
92
|
+
updateView(changed) {
|
|
93
|
+
if (!this._view) return;
|
|
94
|
+
if (changed.has("latitude") || changed.has("longitude")) this._view.setCenter(fromLonLat([this.longitude, this.latitude]));
|
|
95
|
+
if (changed.has("zoom")) this._view.setZoom(this.zoom);
|
|
96
|
+
if (changed.has("bearing")) this._view.setRotation(this.bearing * Math.PI / 180);
|
|
97
|
+
if (changed.has("minZoom")) this._view.setMinZoom(this.minZoom);
|
|
98
|
+
if (changed.has("maxZoom")) this._view.setMaxZoom(this.maxZoom);
|
|
99
|
+
}
|
|
100
|
+
invalidateSize() {
|
|
101
|
+
this._map?.updateSize();
|
|
102
|
+
}
|
|
103
|
+
flyTo(options) {
|
|
104
|
+
this._view?.animate({
|
|
105
|
+
center: fromLonLat([options.center.lng, options.center.lat]),
|
|
106
|
+
zoom: options.zoom,
|
|
107
|
+
rotation: options.bearing ? options.bearing * Math.PI / 180 : void 0,
|
|
108
|
+
duration: options.duration ?? 1e3
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
fitBounds(options) {
|
|
112
|
+
if (!this._view || !this._map) return;
|
|
113
|
+
const sw = fromLonLat([options.bounds.west, options.bounds.south]);
|
|
114
|
+
const ne = fromLonLat([options.bounds.east, options.bounds.north]);
|
|
115
|
+
this._view.fit([
|
|
116
|
+
sw[0],
|
|
117
|
+
sw[1],
|
|
118
|
+
ne[0],
|
|
119
|
+
ne[1]
|
|
120
|
+
], {
|
|
121
|
+
padding: options.padding ? [
|
|
122
|
+
options.padding,
|
|
123
|
+
options.padding,
|
|
124
|
+
options.padding,
|
|
125
|
+
options.padding
|
|
126
|
+
] : void 0,
|
|
127
|
+
maxZoom: options.maxZoom,
|
|
128
|
+
duration: options.duration ?? 1e3
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
SigveloOlMap = __decorate([customElement("sigvelo-ol-map")], SigveloOlMap);
|
|
133
|
+
//#endregion
|
|
2
134
|
export { SigveloOlMap };
|
|
@@ -1,2 +1,97 @@
|
|
|
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 { fromLonLat } from "ol/proj.js";
|
|
5
|
+
import { findMapElement } from "@mcp-b/geo-support/base/find-map-element";
|
|
6
|
+
import styles from "@mcp-b/geo-support/styles/map-child.styles";
|
|
7
|
+
import Overlay from "ol/Overlay.js";
|
|
8
|
+
import { clonePopupContent } from "@mcp-b/geo-support/base/popup-content";
|
|
9
|
+
//#region src/components/marker/marker.ts
|
|
10
|
+
let SigveloOlMarker = class SigveloOlMarker extends LitElement {
|
|
11
|
+
constructor(..._args) {
|
|
12
|
+
super(..._args);
|
|
13
|
+
this.latitude = 0;
|
|
14
|
+
this.longitude = 0;
|
|
15
|
+
this.color = "#3fb1ce";
|
|
16
|
+
this.title = "";
|
|
17
|
+
this._overlay = null;
|
|
18
|
+
this._markerEl = null;
|
|
19
|
+
this._mapEl = null;
|
|
20
|
+
this._popupOverlay = null;
|
|
21
|
+
}
|
|
22
|
+
static {
|
|
23
|
+
this.styles = [styles];
|
|
24
|
+
}
|
|
25
|
+
async connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
28
|
+
await this._mapEl?.whenMapReady(this, () => this._addMarker());
|
|
29
|
+
}
|
|
30
|
+
disconnectedCallback() {
|
|
31
|
+
super.disconnectedCallback();
|
|
32
|
+
if (this._overlay && this._mapEl?.map) this._mapEl.map.removeOverlay(this._overlay);
|
|
33
|
+
this._overlay = null;
|
|
34
|
+
this._markerEl = null;
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
_addMarker() {
|
|
38
|
+
if (!this._mapEl?.map) return;
|
|
39
|
+
this._markerEl = document.createElement("div");
|
|
40
|
+
if (this.title) this._markerEl.title = this.title;
|
|
41
|
+
this._markerEl.style.cursor = "pointer";
|
|
42
|
+
this._markerEl.innerHTML = `
|
|
43
|
+
<svg viewBox="0 0 27 43" xmlns="http://www.w3.org/2000/svg"
|
|
44
|
+
width="25" height="41"
|
|
45
|
+
style="filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));">
|
|
46
|
+
<path d="M13.5 0C6 0 0 6 0 13.5C0 25 13.5 43 13.5 43S27 25 27 13.5C27 6 21 0 13.5 0Z"
|
|
47
|
+
fill="${this.color}" stroke="white" stroke-width="1.5"/>
|
|
48
|
+
<circle cx="13.5" cy="13.5" r="5" fill="white"/>
|
|
49
|
+
</svg>
|
|
50
|
+
`;
|
|
51
|
+
const popupEl = this.querySelector("sigvelo-ol-popup");
|
|
52
|
+
if (popupEl) {
|
|
53
|
+
this._markerEl.style.cursor = "pointer";
|
|
54
|
+
this._markerEl.addEventListener("click", () => {
|
|
55
|
+
this._showPopup(popupEl);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
this._overlay = new Overlay({
|
|
59
|
+
position: fromLonLat([this.longitude, this.latitude]),
|
|
60
|
+
positioning: "bottom-center",
|
|
61
|
+
element: this._markerEl,
|
|
62
|
+
stopEvent: false
|
|
63
|
+
});
|
|
64
|
+
this._mapEl.map.addOverlay(this._overlay);
|
|
65
|
+
}
|
|
66
|
+
/** @internal */
|
|
67
|
+
_showPopup(popupEl) {
|
|
68
|
+
if (!this._mapEl?.map) return;
|
|
69
|
+
if (this._popupOverlay) this._mapEl.map.removeOverlay(this._popupOverlay);
|
|
70
|
+
const content = clonePopupContent(popupEl);
|
|
71
|
+
content.style.background = "white";
|
|
72
|
+
content.style.padding = "8px 12px";
|
|
73
|
+
content.style.borderRadius = "4px";
|
|
74
|
+
content.style.boxShadow = "0 2px 8px rgba(0,0,0,0.2)";
|
|
75
|
+
content.style.transform = "translate(-50%, -8px)";
|
|
76
|
+
this._popupOverlay = new Overlay({
|
|
77
|
+
position: fromLonLat([this.longitude, this.latitude]),
|
|
78
|
+
positioning: "bottom-center",
|
|
79
|
+
element: content,
|
|
80
|
+
offset: [0, -45]
|
|
81
|
+
});
|
|
82
|
+
this._mapEl.map.addOverlay(this._popupOverlay);
|
|
83
|
+
}
|
|
84
|
+
updated() {
|
|
85
|
+
if (this._overlay) this._overlay.setPosition(fromLonLat([this.longitude, this.latitude]));
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
return html` <slot></slot> `;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
__decorate([property({ type: Number })], SigveloOlMarker.prototype, "latitude", void 0);
|
|
92
|
+
__decorate([property({ type: Number })], SigveloOlMarker.prototype, "longitude", void 0);
|
|
93
|
+
__decorate([property()], SigveloOlMarker.prototype, "color", void 0);
|
|
94
|
+
__decorate([property()], SigveloOlMarker.prototype, "title", void 0);
|
|
95
|
+
SigveloOlMarker = __decorate([customElement("sigvelo-ol-marker")], SigveloOlMarker);
|
|
96
|
+
//#endregion
|
|
2
97
|
export { SigveloOlMarker };
|