@mcp-b/geo-openlayers 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.
@@ -1,89 +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 { Stroke, Style } from "ol/style.js";
8
- import Feature from "ol/Feature.js";
9
- import LineString from "ol/geom/LineString.js";
10
- //#region src/components/polyline/polyline.styles.ts
11
- var polyline_styles_default = css`
12
- :host {
13
- display: none;
14
- }
15
- `;
16
- //#endregion
17
- //#region src/components/polyline/polyline.ts
18
- let SigveloOlPolyline = class SigveloOlPolyline extends LitElement {
19
- constructor(..._args) {
20
- super(..._args);
21
- this.positions = [];
22
- this.color = "#3388ff";
23
- this.width = 3;
24
- this.opacity = 1;
25
- this.dashArray = [];
26
- this._layer = null;
27
- this._feature = null;
28
- this._mapEl = null;
29
- }
30
- static {
31
- this.styles = [polyline_styles_default];
32
- }
33
- async connectedCallback() {
34
- super.connectedCallback();
35
- this._mapEl = this.closest("sigvelo-ol-map");
36
- if (this._mapEl) {
37
- await this._mapEl.mapReady;
38
- this._addLine();
39
- }
40
- }
41
- disconnectedCallback() {
42
- super.disconnectedCallback();
43
- if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
44
- this._layer = null;
45
- this._feature = null;
46
- }
47
- /** @internal */
48
- _toCoords() {
49
- return this.positions.map(([lat, lng]) => fromLonLat([lng, lat]));
50
- }
51
- /** @internal */
52
- _hexToRgba(hex, opacity) {
53
- return `rgba(${parseInt(hex.slice(1, 3), 16)}, ${parseInt(hex.slice(3, 5), 16)}, ${parseInt(hex.slice(5, 7), 16)}, ${opacity})`;
54
- }
55
- /** @internal */
56
- _addLine() {
57
- if (!this._mapEl?.map || this.positions.length < 2) return;
58
- this._feature = new Feature({ geometry: new LineString(this._toCoords()) });
59
- this._layer = new VectorLayer({
60
- source: new VectorSource({ features: [this._feature] }),
61
- style: new Style({ stroke: new Stroke({
62
- color: this._hexToRgba(this.color, this.opacity),
63
- width: this.width,
64
- lineDash: this.dashArray.length ? this.dashArray : void 0
65
- }) })
66
- });
67
- this._mapEl.map.addLayer(this._layer);
68
- }
69
- updated(changed) {
70
- if (!this._feature || !this._layer) return;
71
- if (changed.has("positions")) this._feature.getGeometry().setCoordinates(this._toCoords());
72
- if (changed.has("color") || changed.has("width") || changed.has("opacity") || changed.has("dashArray")) this._layer.setStyle(new Style({ stroke: new Stroke({
73
- color: this._hexToRgba(this.color, this.opacity),
74
- width: this.width,
75
- lineDash: this.dashArray.length ? this.dashArray : void 0
76
- }) }));
77
- }
78
- render() {
79
- return html``;
80
- }
81
- };
82
- __decorate([property({ attribute: false })], SigveloOlPolyline.prototype, "positions", void 0);
83
- __decorate([property()], SigveloOlPolyline.prototype, "color", void 0);
84
- __decorate([property({ type: Number })], SigveloOlPolyline.prototype, "width", void 0);
85
- __decorate([property({ type: Number })], SigveloOlPolyline.prototype, "opacity", void 0);
86
- __decorate([property({ attribute: false })], SigveloOlPolyline.prototype, "dashArray", void 0);
87
- SigveloOlPolyline = __decorate([customElement("sigvelo-ol-polyline")], SigveloOlPolyline);
88
- //#endregion
89
- export { SigveloOlPolyline as t };
@@ -1,30 +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/popup/popup.styles.ts
5
- var popup_styles_default = css`
6
- :host {
7
- display: none;
8
- }
9
- `;
10
- //#endregion
11
- //#region src/components/popup/popup.ts
12
- let SigveloOlPopup = class SigveloOlPopup extends LitElement {
13
- constructor(..._args) {
14
- super(..._args);
15
- this.maxWidth = 300;
16
- }
17
- static {
18
- this.styles = [popup_styles_default];
19
- }
20
- render() {
21
- return html` <slot></slot> `;
22
- }
23
- };
24
- __decorate([property({
25
- attribute: "max-width",
26
- type: Number
27
- })], SigveloOlPopup.prototype, "maxWidth", void 0);
28
- SigveloOlPopup = __decorate([customElement("sigvelo-ol-popup")], SigveloOlPopup);
29
- //#endregion
30
- export { SigveloOlPopup as t };
@@ -1,57 +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 ScaleLine from "ol/control/ScaleLine.js";
5
- //#region src/components/scale-control/scale-control.styles.ts
6
- var scale_control_styles_default = css`
7
- :host {
8
- display: none;
9
- }
10
- `;
11
- //#endregion
12
- //#region src/components/scale-control/scale-control.ts
13
- let SigveloOlScaleControl = class SigveloOlScaleControl extends LitElement {
14
- constructor(..._args) {
15
- super(..._args);
16
- this.units = "metric";
17
- this.minWidth = 64;
18
- this._control = null;
19
- this._mapEl = null;
20
- }
21
- static {
22
- this.styles = [scale_control_styles_default];
23
- }
24
- async connectedCallback() {
25
- super.connectedCallback();
26
- this._mapEl = this.closest("sigvelo-ol-map");
27
- if (this._mapEl) {
28
- await this._mapEl.mapReady;
29
- this._addControl();
30
- }
31
- }
32
- disconnectedCallback() {
33
- super.disconnectedCallback();
34
- if (this._control && this._mapEl?.map) this._mapEl.map.removeControl(this._control);
35
- this._control = null;
36
- }
37
- /** @internal */
38
- _addControl() {
39
- if (!this._mapEl?.map) return;
40
- this._control = new ScaleLine({
41
- units: this.units,
42
- minWidth: this.minWidth
43
- });
44
- this._mapEl.map.addControl(this._control);
45
- }
46
- render() {
47
- return html``;
48
- }
49
- };
50
- __decorate([property()], SigveloOlScaleControl.prototype, "units", void 0);
51
- __decorate([property({
52
- attribute: "min-width",
53
- type: Number
54
- })], SigveloOlScaleControl.prototype, "minWidth", void 0);
55
- SigveloOlScaleControl = __decorate([customElement("sigvelo-ol-scale-control")], SigveloOlScaleControl);
56
- //#endregion
57
- export { SigveloOlScaleControl as t };
@@ -1,73 +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 TileLayer from "ol/layer/Tile.js";
5
- import OSM from "ol/source/OSM.js";
6
- import XYZ from "ol/source/XYZ.js";
7
- //#region src/components/tilelayer/tilelayer.styles.ts
8
- var tilelayer_styles_default = css`
9
- :host {
10
- display: none;
11
- }
12
- `;
13
- //#endregion
14
- //#region src/components/tilelayer/tilelayer.ts
15
- let SigveloOlTilelayer = class SigveloOlTilelayer extends LitElement {
16
- constructor(..._args) {
17
- super(..._args);
18
- this.url = "";
19
- this.attribution = "";
20
- this.opacity = 1;
21
- this._layer = null;
22
- this._mapEl = null;
23
- }
24
- static {
25
- this.styles = [tilelayer_styles_default];
26
- }
27
- async connectedCallback() {
28
- super.connectedCallback();
29
- this._mapEl = this.closest("sigvelo-ol-map");
30
- if (this._mapEl) {
31
- await this._mapEl.mapReady;
32
- this._addLayer();
33
- }
34
- }
35
- disconnectedCallback() {
36
- super.disconnectedCallback();
37
- this._removeLayer();
38
- }
39
- /** @internal */
40
- _addLayer() {
41
- if (!this._mapEl?.map) return;
42
- const source = this.url ? new XYZ({
43
- url: this.url,
44
- attributions: this.attribution || void 0
45
- }) : new OSM();
46
- this._layer = new TileLayer({
47
- source,
48
- opacity: this.opacity
49
- });
50
- this._mapEl.map.addLayer(this._layer);
51
- }
52
- /** @internal */
53
- _removeLayer() {
54
- if (this._layer && this._mapEl?.map) this._mapEl.map.removeLayer(this._layer);
55
- this._layer = null;
56
- }
57
- updated(changed) {
58
- if (changed.has("url")) {
59
- this._removeLayer();
60
- this._addLayer();
61
- }
62
- if (changed.has("opacity") && this._layer) this._layer.setOpacity(this.opacity);
63
- }
64
- render() {
65
- return html``;
66
- }
67
- };
68
- __decorate([property()], SigveloOlTilelayer.prototype, "url", void 0);
69
- __decorate([property()], SigveloOlTilelayer.prototype, "attribution", void 0);
70
- __decorate([property({ type: Number })], SigveloOlTilelayer.prototype, "opacity", void 0);
71
- SigveloOlTilelayer = __decorate([customElement("sigvelo-ol-tilelayer")], SigveloOlTilelayer);
72
- //#endregion
73
- export { SigveloOlTilelayer as t };