@mcp-b/geo-openlayers 0.2.22 → 0.3.1
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 +181 -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
|
@@ -1,2 +1,57 @@
|
|
|
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
|
+
//#region src/components/overlay/overlay.ts
|
|
9
|
+
let SigveloOlOverlay = class SigveloOlOverlay extends LitElement {
|
|
10
|
+
constructor(..._args) {
|
|
11
|
+
super(..._args);
|
|
12
|
+
this.latitude = 0;
|
|
13
|
+
this.longitude = 0;
|
|
14
|
+
this.positioning = "bottom-center";
|
|
15
|
+
this._overlay = null;
|
|
16
|
+
this._contentEl = null;
|
|
17
|
+
this._mapEl = null;
|
|
18
|
+
}
|
|
19
|
+
static {
|
|
20
|
+
this.styles = [styles];
|
|
21
|
+
}
|
|
22
|
+
async connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
25
|
+
await this._mapEl?.whenMapReady(this, () => this._addOverlay());
|
|
26
|
+
}
|
|
27
|
+
disconnectedCallback() {
|
|
28
|
+
super.disconnectedCallback();
|
|
29
|
+
if (this._overlay && this._mapEl?.map) this._mapEl.map.removeOverlay(this._overlay);
|
|
30
|
+
this._overlay = null;
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
33
|
+
_addOverlay() {
|
|
34
|
+
if (!this._mapEl?.map) return;
|
|
35
|
+
this._contentEl = document.createElement("div");
|
|
36
|
+
for (const node of Array.from(this.childNodes)) this._contentEl.appendChild(node.cloneNode(true));
|
|
37
|
+
this._overlay = new Overlay({
|
|
38
|
+
position: fromLonLat([this.longitude, this.latitude]),
|
|
39
|
+
positioning: this.positioning,
|
|
40
|
+
element: this._contentEl,
|
|
41
|
+
stopEvent: false
|
|
42
|
+
});
|
|
43
|
+
this._mapEl.map.addOverlay(this._overlay);
|
|
44
|
+
}
|
|
45
|
+
updated() {
|
|
46
|
+
if (this._overlay) this._overlay.setPosition(fromLonLat([this.longitude, this.latitude]));
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
return html` <slot></slot> `;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
__decorate([property({ type: Number })], SigveloOlOverlay.prototype, "latitude", void 0);
|
|
53
|
+
__decorate([property({ type: Number })], SigveloOlOverlay.prototype, "longitude", void 0);
|
|
54
|
+
__decorate([property()], SigveloOlOverlay.prototype, "positioning", void 0);
|
|
55
|
+
SigveloOlOverlay = __decorate([customElement("sigvelo-ol-overlay")], SigveloOlOverlay);
|
|
56
|
+
//#endregion
|
|
2
57
|
export { SigveloOlOverlay };
|
|
@@ -30,8 +30,6 @@ declare class SigveloOlPolygon extends LitElement {
|
|
|
30
30
|
/** @internal */
|
|
31
31
|
private _toCoords;
|
|
32
32
|
/** @internal */
|
|
33
|
-
private _hexToRgba;
|
|
34
|
-
/** @internal */
|
|
35
33
|
private _addPolygon;
|
|
36
34
|
protected updated(changed: PropertyValues): void;
|
|
37
35
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -1,2 +1,94 @@
|
|
|
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 Polygon from "ol/geom/Polygon.js";
|
|
13
|
+
//#region src/components/polygon/polygon.ts
|
|
14
|
+
let SigveloOlPolygon = class SigveloOlPolygon extends LitElement {
|
|
15
|
+
constructor(..._args) {
|
|
16
|
+
super(..._args);
|
|
17
|
+
this.positions = [];
|
|
18
|
+
this.fillColor = "#3388ff";
|
|
19
|
+
this.fillOpacity = .2;
|
|
20
|
+
this.strokeColor = "#3388ff";
|
|
21
|
+
this.strokeWidth = 2;
|
|
22
|
+
this._layer = null;
|
|
23
|
+
this._feature = null;
|
|
24
|
+
this._mapEl = null;
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.styles = [styles];
|
|
28
|
+
}
|
|
29
|
+
async connectedCallback() {
|
|
30
|
+
super.connectedCallback();
|
|
31
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
32
|
+
await this._mapEl?.whenMapReady(this, () => this._addPolygon());
|
|
33
|
+
}
|
|
34
|
+
disconnectedCallback() {
|
|
35
|
+
super.disconnectedCallback();
|
|
36
|
+
if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
|
|
37
|
+
this._layer = null;
|
|
38
|
+
this._feature = null;
|
|
39
|
+
}
|
|
40
|
+
/** @internal */
|
|
41
|
+
_toCoords() {
|
|
42
|
+
const ring = this.positions.map(([lat, lng]) => fromLonLat([lng, lat]));
|
|
43
|
+
if (ring.length > 0) {
|
|
44
|
+
const first = ring[0];
|
|
45
|
+
const last = ring[ring.length - 1];
|
|
46
|
+
if (first[0] !== last[0] || first[1] !== last[1]) ring.push([...first]);
|
|
47
|
+
}
|
|
48
|
+
return [ring];
|
|
49
|
+
}
|
|
50
|
+
/** @internal */
|
|
51
|
+
_addPolygon() {
|
|
52
|
+
if (!this._mapEl?.map || this.positions.length < 3) return;
|
|
53
|
+
this._feature = new Feature({ geometry: new Polygon(this._toCoords()) });
|
|
54
|
+
this._layer = new VectorLayer({
|
|
55
|
+
source: new VectorSource({ features: [this._feature] }),
|
|
56
|
+
style: new Style({
|
|
57
|
+
fill: new Fill({ color: hexToRgba(this.fillColor, this.fillOpacity) }),
|
|
58
|
+
stroke: new Stroke({
|
|
59
|
+
color: this.strokeColor,
|
|
60
|
+
width: this.strokeWidth
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
this._mapEl.map.addLayer(this._layer);
|
|
65
|
+
}
|
|
66
|
+
updated(changed) {
|
|
67
|
+
if (!this._feature || !this._layer) return;
|
|
68
|
+
if (changed.has("positions")) this._feature.getGeometry().setCoordinates(this._toCoords());
|
|
69
|
+
if (changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth")) this._layer.setStyle(new Style({
|
|
70
|
+
fill: new Fill({ color: hexToRgba(this.fillColor, this.fillOpacity) }),
|
|
71
|
+
stroke: new Stroke({
|
|
72
|
+
color: this.strokeColor,
|
|
73
|
+
width: this.strokeWidth
|
|
74
|
+
})
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
return html``;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
__decorate([property({ attribute: false })], SigveloOlPolygon.prototype, "positions", void 0);
|
|
82
|
+
__decorate([property({ attribute: "fill-color" })], SigveloOlPolygon.prototype, "fillColor", void 0);
|
|
83
|
+
__decorate([property({
|
|
84
|
+
attribute: "fill-opacity",
|
|
85
|
+
type: Number
|
|
86
|
+
})], SigveloOlPolygon.prototype, "fillOpacity", void 0);
|
|
87
|
+
__decorate([property({ attribute: "stroke-color" })], SigveloOlPolygon.prototype, "strokeColor", void 0);
|
|
88
|
+
__decorate([property({
|
|
89
|
+
attribute: "stroke-width",
|
|
90
|
+
type: Number
|
|
91
|
+
})], SigveloOlPolygon.prototype, "strokeWidth", void 0);
|
|
92
|
+
SigveloOlPolygon = __decorate([customElement("sigvelo-ol-polygon")], SigveloOlPolygon);
|
|
93
|
+
//#endregion
|
|
2
94
|
export { SigveloOlPolygon };
|
|
@@ -30,8 +30,6 @@ declare class SigveloOlPolyline extends LitElement {
|
|
|
30
30
|
/** @internal */
|
|
31
31
|
private _toCoords;
|
|
32
32
|
/** @internal */
|
|
33
|
-
private _hexToRgba;
|
|
34
|
-
/** @internal */
|
|
35
33
|
private _addLine;
|
|
36
34
|
protected updated(changed: PropertyValues): void;
|
|
37
35
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -1,2 +1,78 @@
|
|
|
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 { Stroke, Style } from "ol/style.js";
|
|
11
|
+
import Feature from "ol/Feature.js";
|
|
12
|
+
import LineString from "ol/geom/LineString.js";
|
|
13
|
+
//#region src/components/polyline/polyline.ts
|
|
14
|
+
let SigveloOlPolyline = class SigveloOlPolyline extends LitElement {
|
|
15
|
+
constructor(..._args) {
|
|
16
|
+
super(..._args);
|
|
17
|
+
this.positions = [];
|
|
18
|
+
this.color = "#3388ff";
|
|
19
|
+
this.width = 3;
|
|
20
|
+
this.opacity = 1;
|
|
21
|
+
this.dashArray = [];
|
|
22
|
+
this._layer = null;
|
|
23
|
+
this._feature = null;
|
|
24
|
+
this._mapEl = null;
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.styles = [styles];
|
|
28
|
+
}
|
|
29
|
+
async connectedCallback() {
|
|
30
|
+
super.connectedCallback();
|
|
31
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
32
|
+
await this._mapEl?.whenMapReady(this, () => this._addLine());
|
|
33
|
+
}
|
|
34
|
+
disconnectedCallback() {
|
|
35
|
+
super.disconnectedCallback();
|
|
36
|
+
if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
|
|
37
|
+
this._layer = null;
|
|
38
|
+
this._feature = null;
|
|
39
|
+
}
|
|
40
|
+
/** @internal */
|
|
41
|
+
_toCoords() {
|
|
42
|
+
return this.positions.map(([lat, lng]) => fromLonLat([lng, lat]));
|
|
43
|
+
}
|
|
44
|
+
/** @internal */
|
|
45
|
+
_addLine() {
|
|
46
|
+
if (!this._mapEl?.map || this.positions.length < 2) return;
|
|
47
|
+
this._feature = new Feature({ geometry: new LineString(this._toCoords()) });
|
|
48
|
+
this._layer = new VectorLayer({
|
|
49
|
+
source: new VectorSource({ features: [this._feature] }),
|
|
50
|
+
style: new Style({ stroke: new Stroke({
|
|
51
|
+
color: hexToRgba(this.color, this.opacity),
|
|
52
|
+
width: this.width,
|
|
53
|
+
lineDash: this.dashArray.length ? this.dashArray : void 0
|
|
54
|
+
}) })
|
|
55
|
+
});
|
|
56
|
+
this._mapEl.map.addLayer(this._layer);
|
|
57
|
+
}
|
|
58
|
+
updated(changed) {
|
|
59
|
+
if (!this._feature || !this._layer) return;
|
|
60
|
+
if (changed.has("positions")) this._feature.getGeometry().setCoordinates(this._toCoords());
|
|
61
|
+
if (changed.has("color") || changed.has("width") || changed.has("opacity") || changed.has("dashArray")) this._layer.setStyle(new Style({ stroke: new Stroke({
|
|
62
|
+
color: hexToRgba(this.color, this.opacity),
|
|
63
|
+
width: this.width,
|
|
64
|
+
lineDash: this.dashArray.length ? this.dashArray : void 0
|
|
65
|
+
}) }));
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
return html``;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
__decorate([property({ attribute: false })], SigveloOlPolyline.prototype, "positions", void 0);
|
|
72
|
+
__decorate([property()], SigveloOlPolyline.prototype, "color", void 0);
|
|
73
|
+
__decorate([property({ type: Number })], SigveloOlPolyline.prototype, "width", void 0);
|
|
74
|
+
__decorate([property({ type: Number })], SigveloOlPolyline.prototype, "opacity", void 0);
|
|
75
|
+
__decorate([property({ attribute: false })], SigveloOlPolyline.prototype, "dashArray", void 0);
|
|
76
|
+
SigveloOlPolyline = __decorate([customElement("sigvelo-ol-polyline")], SigveloOlPolyline);
|
|
77
|
+
//#endregion
|
|
2
78
|
export { SigveloOlPolyline };
|
|
@@ -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 SigveloOlPopup = class SigveloOlPopup 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
|
+
})], SigveloOlPopup.prototype, "maxWidth", void 0);
|
|
22
|
+
SigveloOlPopup = __decorate([customElement("sigvelo-ol-popup")], SigveloOlPopup);
|
|
23
|
+
//#endregion
|
|
2
24
|
export { SigveloOlPopup };
|
|
@@ -1,2 +1,49 @@
|
|
|
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
|
+
import ScaleLine from "ol/control/ScaleLine.js";
|
|
7
|
+
//#region src/components/scale-control/scale-control.ts
|
|
8
|
+
let SigveloOlScaleControl = class SigveloOlScaleControl extends LitElement {
|
|
9
|
+
constructor(..._args) {
|
|
10
|
+
super(..._args);
|
|
11
|
+
this.units = "metric";
|
|
12
|
+
this.minWidth = 64;
|
|
13
|
+
this._control = null;
|
|
14
|
+
this._mapEl = null;
|
|
15
|
+
}
|
|
16
|
+
static {
|
|
17
|
+
this.styles = [styles];
|
|
18
|
+
}
|
|
19
|
+
async connectedCallback() {
|
|
20
|
+
super.connectedCallback();
|
|
21
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
22
|
+
await this._mapEl?.whenMapReady(this, () => this._addControl());
|
|
23
|
+
}
|
|
24
|
+
disconnectedCallback() {
|
|
25
|
+
super.disconnectedCallback();
|
|
26
|
+
if (this._control && this._mapEl?.map) this._mapEl.map.removeControl(this._control);
|
|
27
|
+
this._control = null;
|
|
28
|
+
}
|
|
29
|
+
/** @internal */
|
|
30
|
+
_addControl() {
|
|
31
|
+
if (!this._mapEl?.map) return;
|
|
32
|
+
this._control = new ScaleLine({
|
|
33
|
+
units: this.units,
|
|
34
|
+
minWidth: this.minWidth
|
|
35
|
+
});
|
|
36
|
+
this._mapEl.map.addControl(this._control);
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
return html``;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
__decorate([property()], SigveloOlScaleControl.prototype, "units", void 0);
|
|
43
|
+
__decorate([property({
|
|
44
|
+
attribute: "min-width",
|
|
45
|
+
type: Number
|
|
46
|
+
})], SigveloOlScaleControl.prototype, "minWidth", void 0);
|
|
47
|
+
SigveloOlScaleControl = __decorate([customElement("sigvelo-ol-scale-control")], SigveloOlScaleControl);
|
|
48
|
+
//#endregion
|
|
2
49
|
export { SigveloOlScaleControl };
|
|
@@ -1,2 +1,65 @@
|
|
|
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 TileLayer from "ol/layer/Tile.js";
|
|
5
|
+
import OSM from "ol/source/OSM.js";
|
|
6
|
+
import XYZ from "ol/source/XYZ.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
|
+
//#region src/components/tilelayer/tilelayer.ts
|
|
10
|
+
let SigveloOlTilelayer = class SigveloOlTilelayer extends LitElement {
|
|
11
|
+
constructor(..._args) {
|
|
12
|
+
super(..._args);
|
|
13
|
+
this.url = "";
|
|
14
|
+
this.attribution = "";
|
|
15
|
+
this.opacity = 1;
|
|
16
|
+
this._layer = null;
|
|
17
|
+
this._mapEl = null;
|
|
18
|
+
}
|
|
19
|
+
static {
|
|
20
|
+
this.styles = [styles];
|
|
21
|
+
}
|
|
22
|
+
async connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
this._mapEl = findMapElement(this, "sigvelo-ol-map");
|
|
25
|
+
await this._mapEl?.whenMapReady(this, () => this._addLayer());
|
|
26
|
+
}
|
|
27
|
+
disconnectedCallback() {
|
|
28
|
+
super.disconnectedCallback();
|
|
29
|
+
this._removeLayer();
|
|
30
|
+
}
|
|
31
|
+
/** @internal */
|
|
32
|
+
_addLayer() {
|
|
33
|
+
if (!this._mapEl?.map) return;
|
|
34
|
+
const source = this.url ? new XYZ({
|
|
35
|
+
url: this.url,
|
|
36
|
+
attributions: this.attribution || void 0
|
|
37
|
+
}) : new OSM();
|
|
38
|
+
this._layer = new TileLayer({
|
|
39
|
+
source,
|
|
40
|
+
opacity: this.opacity
|
|
41
|
+
});
|
|
42
|
+
this._mapEl.map.addLayer(this._layer);
|
|
43
|
+
}
|
|
44
|
+
/** @internal */
|
|
45
|
+
_removeLayer() {
|
|
46
|
+
if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
|
|
47
|
+
this._layer = null;
|
|
48
|
+
}
|
|
49
|
+
updated(changed) {
|
|
50
|
+
if (changed.has("url")) {
|
|
51
|
+
this._removeLayer();
|
|
52
|
+
this._addLayer();
|
|
53
|
+
}
|
|
54
|
+
if (changed.has("opacity") && this._layer) this._layer.setOpacity(this.opacity);
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
return html``;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
__decorate([property()], SigveloOlTilelayer.prototype, "url", void 0);
|
|
61
|
+
__decorate([property()], SigveloOlTilelayer.prototype, "attribution", void 0);
|
|
62
|
+
__decorate([property({ type: Number })], SigveloOlTilelayer.prototype, "opacity", void 0);
|
|
63
|
+
SigveloOlTilelayer = __decorate([customElement("sigvelo-ol-tilelayer")], SigveloOlTilelayer);
|
|
64
|
+
//#endregion
|
|
2
65
|
export { SigveloOlTilelayer };
|
|
@@ -182,7 +182,30 @@
|
|
|
182
182
|
"kind": "class",
|
|
183
183
|
"description": "A generic control container for an OpenLayers map. Wraps arbitrary content\nand adds it as an OL control, positioned in a map corner.",
|
|
184
184
|
"name": "SigveloOlControl",
|
|
185
|
+
"slots": [
|
|
186
|
+
{
|
|
187
|
+
"description": "Control content, retained in the control’s light DOM.",
|
|
188
|
+
"name": ""
|
|
189
|
+
}
|
|
190
|
+
],
|
|
185
191
|
"members": [
|
|
192
|
+
{
|
|
193
|
+
"kind": "method",
|
|
194
|
+
"name": "_removeControl",
|
|
195
|
+
"privacy": "private"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"kind": "field",
|
|
199
|
+
"name": "_stopPlacement",
|
|
200
|
+
"type": {
|
|
201
|
+
"text": "(() => void) | null"
|
|
202
|
+
},
|
|
203
|
+
"privacy": "private",
|
|
204
|
+
"default": "null",
|
|
205
|
+
"parsedType": {
|
|
206
|
+
"text": "null | { }"
|
|
207
|
+
}
|
|
208
|
+
},
|
|
186
209
|
{
|
|
187
210
|
"kind": "field",
|
|
188
211
|
"name": "position",
|
|
@@ -1289,6 +1312,46 @@
|
|
|
1289
1312
|
}
|
|
1290
1313
|
]
|
|
1291
1314
|
},
|
|
1315
|
+
{
|
|
1316
|
+
"kind": "javascript-module",
|
|
1317
|
+
"path": "src/hex-to-rgba.ts",
|
|
1318
|
+
"declarations": [
|
|
1319
|
+
{
|
|
1320
|
+
"kind": "function",
|
|
1321
|
+
"name": "hexToRgba",
|
|
1322
|
+
"return": {
|
|
1323
|
+
"type": {
|
|
1324
|
+
"text": "string"
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1327
|
+
"parameters": [
|
|
1328
|
+
{
|
|
1329
|
+
"name": "hex",
|
|
1330
|
+
"type": {
|
|
1331
|
+
"text": "string"
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
"name": "opacity",
|
|
1336
|
+
"type": {
|
|
1337
|
+
"text": "number"
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
],
|
|
1341
|
+
"description": "Expand a `#rrggbb` color and a separate opacity into the single `rgba()`\nstring OpenLayers styles take. `Fill` and `Stroke` accept one color value\nwith no opacity of their own, so the two component properties have to be\nfolded together before they reach a style.\n\nSix-digit hex only, matching the `fill-color` / `stroke-color` defaults these\ncomponents ship."
|
|
1342
|
+
}
|
|
1343
|
+
],
|
|
1344
|
+
"exports": [
|
|
1345
|
+
{
|
|
1346
|
+
"kind": "js",
|
|
1347
|
+
"name": "hexToRgba",
|
|
1348
|
+
"declaration": {
|
|
1349
|
+
"name": "hexToRgba",
|
|
1350
|
+
"module": "src/hex-to-rgba.ts"
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
]
|
|
1354
|
+
},
|
|
1292
1355
|
{
|
|
1293
1356
|
"kind": "javascript-module",
|
|
1294
1357
|
"path": "src/index.ts",
|
|
@@ -1388,7 +1451,7 @@
|
|
|
1388
1451
|
"package": {
|
|
1389
1452
|
"name": "@mcp-b/geo-openlayers",
|
|
1390
1453
|
"description": "OpenLayers web components for Sigvelo, built with Lit.",
|
|
1391
|
-
"version": "0.
|
|
1454
|
+
"version": "0.3.1",
|
|
1392
1455
|
"license": "MIT"
|
|
1393
1456
|
}
|
|
1394
1457
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/hex-to-rgba.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Expand a `#rrggbb` color and a separate opacity into the single `rgba()`
|
|
4
|
+
* string OpenLayers styles take. `Fill` and `Stroke` accept one color value
|
|
5
|
+
* with no opacity of their own, so the two component properties have to be
|
|
6
|
+
* folded together before they reach a style.
|
|
7
|
+
*
|
|
8
|
+
* Six-digit hex only, matching the `fill-color` / `stroke-color` defaults these
|
|
9
|
+
* components ship.
|
|
10
|
+
*/
|
|
11
|
+
declare function hexToRgba(hex: string, opacity: number): string;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { hexToRgba };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/hex-to-rgba.ts
|
|
2
|
+
/**
|
|
3
|
+
* Expand a `#rrggbb` color and a separate opacity into the single `rgba()`
|
|
4
|
+
* string OpenLayers styles take. `Fill` and `Stroke` accept one color value
|
|
5
|
+
* with no opacity of their own, so the two component properties have to be
|
|
6
|
+
* folded together before they reach a style.
|
|
7
|
+
*
|
|
8
|
+
* Six-digit hex only, matching the `fill-color` / `stroke-color` defaults these
|
|
9
|
+
* components ship.
|
|
10
|
+
*/
|
|
11
|
+
function hexToRgba(hex, opacity) {
|
|
12
|
+
return `rgba(${parseInt(hex.slice(1, 3), 16)}, ${parseInt(hex.slice(3, 5), 16)}, ${parseInt(hex.slice(5, 7), 16)}, ${opacity})`;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { hexToRgba };
|
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 { SigveloOlMap } from "./components/map/map.js";
|
|
2
|
+
import { SigveloOlTilelayer } from "./components/tilelayer/tilelayer.js";
|
|
3
|
+
import { SigveloOlMarker } from "./components/marker/marker.js";
|
|
4
|
+
import { SigveloOlPopup } from "./components/popup/popup.js";
|
|
5
|
+
import { SigveloOlOverlay } from "./components/overlay/overlay.js";
|
|
6
|
+
import { SigveloOlGeojson } from "./components/geojson/geojson.js";
|
|
7
|
+
import { SigveloOlCircle } from "./components/circle/circle.js";
|
|
8
|
+
import { SigveloOlPolyline } from "./components/polyline/polyline.js";
|
|
9
|
+
import { SigveloOlPolygon } from "./components/polygon/polygon.js";
|
|
10
|
+
import { SigveloOlScaleControl } from "./components/scale-control/scale-control.js";
|
|
11
|
+
import { SigveloOlControl } from "./components/control/control.js";
|
|
12
12
|
export { SigveloOlCircle, SigveloOlControl, SigveloOlGeojson, SigveloOlMap, SigveloOlMarker, SigveloOlOverlay, SigveloOlPolygon, SigveloOlPolyline, SigveloOlPopup, SigveloOlScaleControl, SigveloOlTilelayer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-b/geo-openlayers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "OpenLayers web components for Sigvelo, built with Lit.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"custom-elements",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@mcp-b/geo-support": "0.
|
|
39
|
-
"@mcp-b/wc-support": "0.
|
|
38
|
+
"@mcp-b/geo-support": "0.3.1",
|
|
39
|
+
"@mcp-b/wc-support": "0.3.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@custom-elements-manifest/analyzer": "^0.10.10",
|
package/dist/circle-BiLEqiGC.js
DELETED
|
@@ -1,102 +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 { fromLonLat } from "ol/proj.js";
|
|
5
|
-
import VectorLayer from "ol/layer/Vector.js";
|
|
6
|
-
import VectorSource from "ol/source/Vector.js";
|
|
7
|
-
import { Fill, Stroke, Style } from "ol/style.js";
|
|
8
|
-
import Feature from "ol/Feature.js";
|
|
9
|
-
import Circle$1 from "ol/geom/Circle.js";
|
|
10
|
-
//#region src/components/circle/circle.styles.ts
|
|
11
|
-
var circle_styles_default = css`
|
|
12
|
-
:host {
|
|
13
|
-
display: none;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/components/circle/circle.ts
|
|
18
|
-
let SigveloOlCircle = class SigveloOlCircle extends LitElement {
|
|
19
|
-
constructor(..._args) {
|
|
20
|
-
super(..._args);
|
|
21
|
-
this.latitude = 0;
|
|
22
|
-
this.longitude = 0;
|
|
23
|
-
this.radius = 100;
|
|
24
|
-
this.fillColor = "#3388ff";
|
|
25
|
-
this.fillOpacity = .2;
|
|
26
|
-
this.strokeColor = "#3388ff";
|
|
27
|
-
this.strokeWidth = 2;
|
|
28
|
-
this._layer = null;
|
|
29
|
-
this._feature = null;
|
|
30
|
-
this._mapEl = null;
|
|
31
|
-
}
|
|
32
|
-
static {
|
|
33
|
-
this.styles = [circle_styles_default];
|
|
34
|
-
}
|
|
35
|
-
async connectedCallback() {
|
|
36
|
-
super.connectedCallback();
|
|
37
|
-
this._mapEl = this.closest("sigvelo-ol-map");
|
|
38
|
-
if (this._mapEl) {
|
|
39
|
-
await this._mapEl.mapReady;
|
|
40
|
-
this._addCircle();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
disconnectedCallback() {
|
|
44
|
-
super.disconnectedCallback();
|
|
45
|
-
if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
|
|
46
|
-
this._layer = null;
|
|
47
|
-
this._feature = null;
|
|
48
|
-
}
|
|
49
|
-
/** @internal */
|
|
50
|
-
_hexToRgba(hex, opacity) {
|
|
51
|
-
return `rgba(${parseInt(hex.slice(1, 3), 16)}, ${parseInt(hex.slice(3, 5), 16)}, ${parseInt(hex.slice(5, 7), 16)}, ${opacity})`;
|
|
52
|
-
}
|
|
53
|
-
/** @internal */
|
|
54
|
-
_addCircle() {
|
|
55
|
-
if (!this._mapEl?.map) return;
|
|
56
|
-
const geometry = new Circle$1(fromLonLat([this.longitude, this.latitude]), this.radius);
|
|
57
|
-
this._feature = new Feature({ geometry });
|
|
58
|
-
const style = new Style({
|
|
59
|
-
fill: new Fill({ color: this._hexToRgba(this.fillColor, this.fillOpacity) }),
|
|
60
|
-
stroke: new Stroke({
|
|
61
|
-
color: this.strokeColor,
|
|
62
|
-
width: this.strokeWidth
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
this._layer = new VectorLayer({
|
|
66
|
-
source: new VectorSource({ features: [this._feature] }),
|
|
67
|
-
style
|
|
68
|
-
});
|
|
69
|
-
this._mapEl.map.addLayer(this._layer);
|
|
70
|
-
}
|
|
71
|
-
updated(changed) {
|
|
72
|
-
if (!this._feature || !this._layer) return;
|
|
73
|
-
if (changed.has("latitude") || changed.has("longitude")) this._feature.getGeometry().setCenter(fromLonLat([this.longitude, this.latitude]));
|
|
74
|
-
if (changed.has("radius")) this._feature.getGeometry().setRadius(this.radius);
|
|
75
|
-
if (changed.has("fillColor") || changed.has("fillOpacity") || changed.has("strokeColor") || changed.has("strokeWidth")) this._layer.setStyle(new Style({
|
|
76
|
-
fill: new Fill({ color: this._hexToRgba(this.fillColor, this.fillOpacity) }),
|
|
77
|
-
stroke: new Stroke({
|
|
78
|
-
color: this.strokeColor,
|
|
79
|
-
width: this.strokeWidth
|
|
80
|
-
})
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
render() {
|
|
84
|
-
return html``;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
__decorate([property({ type: Number })], SigveloOlCircle.prototype, "latitude", void 0);
|
|
88
|
-
__decorate([property({ type: Number })], SigveloOlCircle.prototype, "longitude", void 0);
|
|
89
|
-
__decorate([property({ type: Number })], SigveloOlCircle.prototype, "radius", void 0);
|
|
90
|
-
__decorate([property({ attribute: "fill-color" })], SigveloOlCircle.prototype, "fillColor", void 0);
|
|
91
|
-
__decorate([property({
|
|
92
|
-
attribute: "fill-opacity",
|
|
93
|
-
type: Number
|
|
94
|
-
})], SigveloOlCircle.prototype, "fillOpacity", void 0);
|
|
95
|
-
__decorate([property({ attribute: "stroke-color" })], SigveloOlCircle.prototype, "strokeColor", void 0);
|
|
96
|
-
__decorate([property({
|
|
97
|
-
attribute: "stroke-width",
|
|
98
|
-
type: Number
|
|
99
|
-
})], SigveloOlCircle.prototype, "strokeWidth", void 0);
|
|
100
|
-
SigveloOlCircle = __decorate([customElement("sigvelo-ol-circle")], SigveloOlCircle);
|
|
101
|
-
//#endregion
|
|
102
|
-
export { SigveloOlCircle as t };
|