@panoramax/web-viewer 5.0.0-develop-d7206514 → 5.0.0-develop-d26305dd

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.
Files changed (152) hide show
  1. package/build/bundle.cjs +3399 -0
  2. package/build/bundle.cjs.map +1 -0
  3. package/build/bundle_photoviewer.cjs +2510 -0
  4. package/build/bundle_photoviewer.cjs.map +1 -0
  5. package/build/cjs/index.js +1 -1
  6. package/build/cjs/index_photoviewer.js +1 -1
  7. package/build/components/core/Basic.css +56 -0
  8. package/build/components/core/Basic.js +378 -0
  9. package/build/components/core/CoverageMap.css +10 -0
  10. package/build/components/core/CoverageMap.js +169 -0
  11. package/build/components/core/Editor.css +33 -0
  12. package/build/components/core/Editor.js +398 -0
  13. package/build/components/core/PhotoViewer.css +70 -0
  14. package/build/components/core/PhotoViewer.js +650 -0
  15. package/build/components/core/Viewer.css +130 -0
  16. package/build/components/core/Viewer.js +711 -0
  17. package/build/components/core/index.js +10 -0
  18. package/build/components/index.js +11 -0
  19. package/build/components/index_photoviewer.js +6 -0
  20. package/build/components/layout/BottomDrawer.js +258 -0
  21. package/build/components/layout/CorneredGrid.js +143 -0
  22. package/build/components/layout/Mini.js +121 -0
  23. package/build/components/layout/Tabs.js +140 -0
  24. package/build/components/layout/index.js +9 -0
  25. package/build/components/menus/LocationPrecisionDoc.js +42 -0
  26. package/build/components/menus/MapBackground.js +110 -0
  27. package/build/components/menus/MapFilters.js +567 -0
  28. package/build/components/menus/MapLayers.js +238 -0
  29. package/build/components/menus/MapLegend.js +68 -0
  30. package/build/components/menus/MiniPictureLegend.js +73 -0
  31. package/build/components/menus/PictureLegend.js +379 -0
  32. package/build/components/menus/PictureMetadata.js +380 -0
  33. package/build/components/menus/PlayerOptions.js +93 -0
  34. package/build/components/menus/QualityScoreDoc.js +42 -0
  35. package/build/components/menus/ReportForm.js +132 -0
  36. package/build/components/menus/SemanticsDoc.js +38 -0
  37. package/build/components/menus/SemanticsDownload.js +33 -0
  38. package/build/components/menus/SemanticsFilters.js +153 -0
  39. package/build/components/menus/SemanticsList.js +413 -0
  40. package/build/components/menus/SemanticsMetadata.js +368 -0
  41. package/build/components/menus/Share.js +105 -0
  42. package/build/components/menus/index.js +22 -0
  43. package/build/components/menus/index_photoviewer.js +11 -0
  44. package/build/components/styles.js +557 -0
  45. package/build/components/ui/AnnotationsSwitch.js +159 -0
  46. package/build/components/ui/Button.js +77 -0
  47. package/build/components/ui/ButtonGroup.css +59 -0
  48. package/build/components/ui/ButtonGroup.js +69 -0
  49. package/build/components/ui/CopyButton.js +110 -0
  50. package/build/components/ui/Grade.js +54 -0
  51. package/build/components/ui/GradeFilter.js +122 -0
  52. package/build/components/ui/IconSwitch.js +193 -0
  53. package/build/components/ui/LinkButton.js +67 -0
  54. package/build/components/ui/ListGroup.js +66 -0
  55. package/build/components/ui/ListItem.js +90 -0
  56. package/build/components/ui/Loader.js +203 -0
  57. package/build/components/ui/Map.css +63 -0
  58. package/build/components/ui/Map.js +853 -0
  59. package/build/components/ui/MapMore.js +175 -0
  60. package/build/components/ui/Photo.css +50 -0
  61. package/build/components/ui/Photo.js +1502 -0
  62. package/build/components/ui/Popup.js +145 -0
  63. package/build/components/ui/ProgressBar.js +104 -0
  64. package/build/components/ui/QualityScore.js +147 -0
  65. package/build/components/ui/SearchBar.js +374 -0
  66. package/build/components/ui/SemanticsEditor.js +191 -0
  67. package/build/components/ui/SemanticsTable.js +88 -0
  68. package/build/components/ui/Switch.js +139 -0
  69. package/build/components/ui/TogglableGroup.js +157 -0
  70. package/build/components/ui/index.js +29 -0
  71. package/build/components/ui/index_photoviewer.js +21 -0
  72. package/build/components/ui/widgets/CopyCoordinates.js +75 -0
  73. package/build/components/ui/widgets/GeoSearch.css +21 -0
  74. package/build/components/ui/widgets/GeoSearch.js +150 -0
  75. package/build/components/ui/widgets/Legend.js +190 -0
  76. package/build/components/ui/widgets/LevelSelect.css +51 -0
  77. package/build/components/ui/widgets/LevelSelect.js +143 -0
  78. package/build/components/ui/widgets/MapFiltersButton.js +114 -0
  79. package/build/components/ui/widgets/MapLayersButton.js +79 -0
  80. package/build/components/ui/widgets/OSMEditors.js +155 -0
  81. package/build/components/ui/widgets/PictureLegendActions.js +99 -0
  82. package/build/components/ui/widgets/Player.css +7 -0
  83. package/build/components/ui/widgets/Player.js +154 -0
  84. package/build/components/ui/widgets/SemanticsFiltersButton.js +65 -0
  85. package/build/components/ui/widgets/Zoom.js +84 -0
  86. package/build/components/ui/widgets/index.js +16 -0
  87. package/build/components/ui/widgets/index_photoviewer.js +7 -0
  88. package/build/esm/components/core/Basic.js +1 -1
  89. package/build/img/arrow_360.svg +14 -0
  90. package/build/img/arrow_flat.svg +11 -0
  91. package/build/img/arrow_triangle.svg +9 -0
  92. package/build/img/arrow_turn.svg +8 -0
  93. package/build/img/bg_aerial.jpg +0 -0
  94. package/build/img/bg_streets.jpg +0 -0
  95. package/build/img/loader_base.jpg +0 -0
  96. package/build/img/logo_dead.svg +91 -0
  97. package/build/img/marker.svg +17 -0
  98. package/build/img/marker_blue.svg +20 -0
  99. package/build/img/osm.svg +49 -0
  100. package/build/img/panoramax.svg +13 -0
  101. package/build/img/switch_big.svg +54 -0
  102. package/build/img/switch_mini.svg +48 -0
  103. package/build/img/wd.svg +1 -0
  104. package/build/index_photoviewer.js +4 -0
  105. package/build/package.json +148 -0
  106. package/build/servers.js +14 -0
  107. package/build/translations/ar.json +1 -0
  108. package/build/translations/be.json +257 -0
  109. package/build/translations/br.json +81 -0
  110. package/build/translations/cy.json +117 -0
  111. package/build/translations/da.json +300 -0
  112. package/build/translations/de.json +309 -0
  113. package/build/translations/en.json +294 -0
  114. package/build/translations/eo.json +235 -0
  115. package/build/translations/es.json +292 -0
  116. package/build/translations/fi.json +1 -0
  117. package/build/translations/fr.json +294 -0
  118. package/build/translations/hr.json +294 -0
  119. package/build/translations/hu.json +294 -0
  120. package/build/translations/it.json +306 -0
  121. package/build/translations/ja.json +182 -0
  122. package/build/translations/ko.json +1 -0
  123. package/build/translations/nl.json +305 -0
  124. package/build/translations/nn.json +1 -0
  125. package/build/translations/pl.json +169 -0
  126. package/build/translations/pt.json +296 -0
  127. package/build/translations/pt_BR.json +304 -0
  128. package/build/translations/sv.json +182 -0
  129. package/build/translations/ti.json +9 -0
  130. package/build/translations/tr.json +297 -0
  131. package/build/translations/uk.json +268 -0
  132. package/build/translations/zh_Hant.json +309 -0
  133. package/build/utils/API.js +928 -0
  134. package/build/utils/InitParameters.js +521 -0
  135. package/build/utils/MapStyleComposer.js +889 -0
  136. package/build/utils/PanoraMapProtocol.js +49 -0
  137. package/build/utils/PhotoAdapter.js +49 -0
  138. package/build/utils/PresetsManager.js +148 -0
  139. package/build/utils/SemanticsMapProtocol.js +144 -0
  140. package/build/utils/URLHandler.js +426 -0
  141. package/build/utils/geocoder.js +203 -0
  142. package/build/utils/i18n.js +128 -0
  143. package/build/utils/index.js +17 -0
  144. package/build/utils/index_photoviewer.js +14 -0
  145. package/build/utils/indoor.js +200 -0
  146. package/build/utils/map.js +788 -0
  147. package/build/utils/picture.js +507 -0
  148. package/build/utils/semantics.js +321 -0
  149. package/build/utils/services.js +148 -0
  150. package/build/utils/utils.js +433 -0
  151. package/build/utils/widgets.js +110 -0
  152. package/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ import { LitElement, css, html, nothing } from "lit";
2
+ import { panel } from "../../styles.js";
3
+ import { fa, onceParentAvailable } from "../../../utils/widgets.js";
4
+ import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
5
+ import { classMap } from "lit/directives/class-map.js";
6
+ import { PanoramaxWebsiteURL } from "../../../utils/services.js";
7
+ import { svgToImg } from "../../../utils/utils.js";
8
+ const PanoramaxImg = await fetch(new URL("../../../img/panoramax.svg", import.meta.url).href).then(res => res.text());
9
+
10
+ /**
11
+ * Legend widget, handling switch between map and photo components.
12
+ * Also displays a default "About Panoramax" message.
13
+ * @class Panoramax.components.ui.widgets.Legend
14
+ * @element pnx-widget-legend
15
+ * @extends [lit.LitElement](https://lit.dev/docs/api/LitElement/)
16
+ * @slot `editors` External links to map editors, or any tool that may be helpful. Defaults to OSM tools (iD & JOSM).
17
+ * @example
18
+ * ```html
19
+ * <!-- Default legend -->
20
+ * <pnx-widget-legend
21
+ * _parent=${viewer}
22
+ * focus="map"
23
+ * picture="PICTURE-ID-IF-ANY"
24
+ * ></pnx-widget-legend>
25
+ *
26
+ * <!-- With custom editor links -->
27
+ * <pnx-widget-legend
28
+ * _parent=${viewer}
29
+ * focus="map"
30
+ * picture="PICTURE-ID-IF-ANY"
31
+ * >
32
+ * <div slot="editors"><a href="http://my.own.tool">Edit in my own tool</a></div>
33
+ * </pnx-widget-legend>
34
+ *
35
+ * <!-- Lighter version -->
36
+ * <pnx-widget-legend
37
+ * _parent=${viewer}
38
+ * focus="pic"
39
+ * picture="PICTURE-ID-IF-ANY"
40
+ * light
41
+ * ></pnx-widget-legend>
42
+ * ```
43
+ */
44
+ export default class Legend extends LitElement {
45
+ /** @private */
46
+ static styles = [panel, css`
47
+ :host {
48
+ pointer-events: none;
49
+ }
50
+ .pnx-panel[part="panel"] {
51
+ border-radius: 10px;
52
+ position: relative;
53
+ max-width: 450px;
54
+ z-index: 121; /* To appear above mini component */
55
+ min-width: unset;
56
+ pointer-events: auto;
57
+ }
58
+ .pnx-panel[part="panel"].pnx-padded {
59
+ padding: 10px;
60
+ width: 250px;
61
+ }
62
+ .presentation {
63
+ font-size: 0.85em;
64
+ line-height: 1em;
65
+ display: flex;
66
+ gap: 5px;
67
+ align-items: center;
68
+ }
69
+ .logo {
70
+ width: 45px;
71
+ }
72
+ pnx-map-legend {
73
+ display: block;
74
+ margin-top: 5px;
75
+ }
76
+
77
+ /* Lighter/smaller version */
78
+ .pnx-panel[part="panel"].pnx-legend-light {
79
+ display: flex;
80
+ gap: 3px;
81
+ padding: 3px 8px 3px 3px;
82
+ width: unset;
83
+ min-width: unset;
84
+ align-items: center;
85
+ font-size: 10px;
86
+ margin-right: -10px;
87
+ margin-bottom: -10px;
88
+ border-radius: 0;
89
+ border-top-left-radius: 5px;
90
+ border-right: none;
91
+ border-bottom: none;
92
+ }
93
+ .pnx-legend-light a,
94
+ .pnx-legend-light .presentation {
95
+ font-size: 10px;
96
+ }
97
+ .pnx-legend-light .logo {
98
+ width: 15px;
99
+ }
100
+
101
+ .pnx-legend-light pnx-map-legend {
102
+ width: max-content;
103
+ margin-top: unset;
104
+ font-size: 10px;
105
+ }
106
+ `];
107
+
108
+ /**
109
+ * Component properties.
110
+ * @memberof Panoramax.components.ui.widgets.Legend#
111
+ * @type {Object}
112
+ * @property {string} [focus] The focused main component (map, pic)
113
+ * @property {string} [picture] The picture ID
114
+ * @property {boolean} [light=false] Lighter version (for iframes)
115
+ */
116
+ static properties = {
117
+ focus: {type: String},
118
+ picture: {type: String},
119
+ light: {type: Boolean},
120
+ };
121
+
122
+ constructor() {
123
+ super();
124
+ this.light = false;
125
+ }
126
+
127
+ /** @private */
128
+ connectedCallback() {
129
+ super.connectedCallback();
130
+ onceParentAvailable(this).then(() => this.requestUpdate());
131
+ }
132
+
133
+ render() {
134
+ const classes = {
135
+ "pnx-panel": true,
136
+ "pnx-padded": this.focus == "map",
137
+ "pnx-legend-light": this.light,
138
+ };
139
+
140
+ const logo = svgToImg(PanoramaxImg);
141
+ logo.classList.add("logo");
142
+
143
+ return html`<div class=${classMap(classes)} part="panel">
144
+ <div
145
+ class="presentation"
146
+ style=${!this.light && this.focus != "map" && this.picture ? "display: none": ""}
147
+ >
148
+ ${logo}
149
+
150
+ ${this.light ? html`
151
+ &copy; <a
152
+ href=${PanoramaxWebsiteURL()}
153
+ title=${this._parent?._t.map.more_panoramax}
154
+ target="_blank"
155
+ >${this._parent?._t.pnx.panoramax}</a> |
156
+ ` : html`
157
+ <div>
158
+ ${this._parent?._t.pnx.whats_panoramax}
159
+ <pnx-link-button
160
+ title=${this._parent?._t.map.more_panoramax}
161
+ kind="superinline"
162
+ href=${PanoramaxWebsiteURL()}
163
+ target="_blank"
164
+ size="sm"
165
+ >
166
+ ${fa(faInfoCircle)}
167
+ </pnx-link-button>
168
+ </div>
169
+ `}
170
+ </div>
171
+ <pnx-picture-legend
172
+ ._parent=${this._parent}
173
+ style=${this.focus == "map" ? "display: none": ""}
174
+ collapsable
175
+ light=${this.light || nothing}
176
+ >
177
+ <slot slot="editors" name="editors">
178
+ <pnx-widget-osmeditors ._parent=${this._parent} />
179
+ </slot>
180
+ </pnx-picture-legend>
181
+ <pnx-map-legend
182
+ ._parent=${this._parent}
183
+ style=${this.focus != "map" ? "display: none": ""}
184
+ light=${this.light || nothing}
185
+ ></pnx-map-legend>
186
+ </div>`;
187
+ }
188
+ }
189
+
190
+ customElements.define("pnx-widget-legend", Legend);
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Common rules
3
+ */
4
+
5
+ /* Long level numbers */
6
+ pnx-level-select pnx-button.pnx-level-long::part(btn) {
7
+ font-size: 0.6em;
8
+ }
9
+
10
+
11
+ /*
12
+ * Shrink selector
13
+ */
14
+
15
+ pnx-level-select pnx-button {
16
+ min-height: fit-content;
17
+ font-family: var(--font-family);
18
+ font-size: 0.9em;
19
+ }
20
+
21
+ pnx-level-select pnx-button.pnx-level-minimal::part(btn) {
22
+ padding: 2px 5px;
23
+ }
24
+
25
+
26
+ /*
27
+ * Expanded selector
28
+ */
29
+
30
+ /* Selected level */
31
+ pnx-level-select pnx-button .pnx-level-active {
32
+ background-color: var(--widget-bg-active);
33
+ border-radius: 13px;
34
+ color: var(--widget-font-active);
35
+ height: 26px;
36
+ line-height: 26px;
37
+ width: 26px;
38
+ }
39
+
40
+ /* Shrink button */
41
+ pnx-level-select pnx-button.pnx-level-shrink::part(btn) {
42
+ border-top: 1px solid #cfcfcf !important;
43
+ }
44
+
45
+ /* Long list of levels scrolling */
46
+ pnx-level-select .pnx-level-scroller {
47
+ overflow-y: auto;
48
+ overflow-x: hidden;
49
+ max-height: 150px;
50
+ scroll-behavior: smooth;
51
+ }
@@ -0,0 +1,143 @@
1
+ import { LitElement, html, nothing } from "lit";
2
+ import { fa, onceParentAvailable } from "../../../utils/widgets.js";
3
+ import { DISABLED_LEVEL } from "../../../utils/indoor.js";
4
+ import {
5
+ faCaretDown, faCaretUp, faTimes
6
+ } from "@fortawesome/free-solid-svg-icons";
7
+ import LevelSelectStyles from "./LevelSelect.css" with { type: "css" };
8
+ import ButtonGroupStyles from "../ButtonGroup.css" with { type: "css" };
9
+ document.adoptedStyleSheets.push(LevelSelectStyles);
10
+ document.adoptedStyleSheets.push(ButtonGroupStyles);
11
+
12
+ /**
13
+ * Widget for indoor level selecting over map.
14
+ * It relies on indoor= MapLibre plugin to work, so this should be enabled before calling this widget.
15
+ * @class Panoramax.components.ui.widgets.LevelSelect
16
+ * @element pnx-level-select
17
+ * @extends [lit.LitElement](https://lit.dev/docs/api/LitElement/)
18
+ * @example
19
+ * ```html
20
+ * <pnx-level-select _parent=${viewer} />
21
+ * ```
22
+ */
23
+ export default class LevelSelect extends LitElement {
24
+ /** @private */
25
+ static properties = {
26
+ _expanded: {state: true},
27
+ };
28
+
29
+ /** @private */
30
+ createRenderRoot() {
31
+ return this;
32
+ }
33
+
34
+ /** @private */
35
+ connectedCallback() {
36
+ super.connectedCallback();
37
+ onceParentAvailable(this)
38
+ .then(this._parent.onceMapReady?.())
39
+ .then(() => {
40
+ this._parent.map.indoorEqual.on("levelchange", () => this.requestUpdate());
41
+ this._parent.map.indoorEqual.on("levelschange", () => this.requestUpdate());
42
+ });
43
+ }
44
+
45
+ /** @private */
46
+ updated(changedProps) {
47
+ super.updated(changedProps);
48
+
49
+ // Make level list scroll to see currently selected level
50
+ if(this._expanded) {
51
+ if(changedProps?.has("_expanded")) {
52
+ this._scrollToCurrentLevel(false, "instant");
53
+ } else {
54
+ this._scrollToCurrentLevel(true, "smooth");
55
+ }
56
+ }
57
+ }
58
+
59
+ /** @private */
60
+ _scrollToCurrentLevel(immediate, behavior) {
61
+ const lvlSelected = this.renderRoot.querySelector(".pnx-level-active");
62
+ setTimeout(
63
+ () => lvlSelected?.scrollIntoView({behavior, block: "center", container: "nearest"}),
64
+ immediate ? 0 : 50
65
+ );
66
+ }
67
+
68
+ /** @private */
69
+ render() {
70
+ const ieq = this._parent.map.indoorEqual;
71
+
72
+ // Disabled level = hide
73
+ if(ieq.level === DISABLED_LEVEL || ieq.levels.length === 0) { return nothing; }
74
+
75
+ // Find upper/lower level
76
+ // Note that levels are reverse sorted
77
+ const lvlId = ieq.levels.findIndex(l => l == ieq.level);
78
+ const lvlUpId = lvlId > 0 ? lvlId - 1 : null;
79
+ const lvlUp = lvlUpId !== null ? ieq.levels[lvlUpId] : null;
80
+ const lvlDownId = lvlId < ieq.levels.length - 1 ? lvlId + 1 : null;
81
+ const lvlDown = lvlDownId !== null ? ieq.levels[lvlDownId] : null;
82
+
83
+ return html`
84
+ <pnx-button-group
85
+ dir="column"
86
+ size="xl"
87
+ class="pnx-print-hidden"
88
+ >
89
+ <pnx-button
90
+ kind="superflat"
91
+ @click=${() => ieq.setLevel(lvlUp)}
92
+ .disabled=${lvlUp === null}
93
+ class="pnx-level-minimal"
94
+ title=${this._parent?._t?.pnx.indoor_selector_levelup}
95
+ >${fa(faCaretUp)}</pnx-button>
96
+
97
+ ${this._expanded ? html`
98
+ <pnx-button-group
99
+ dir="column"
100
+ size="xl"
101
+ class="pnx-print-hidden pnx-level-scroller"
102
+ >
103
+ ${ieq.levels.map(l => html`
104
+ <pnx-button
105
+ kind="superflat"
106
+ @click=${() => ieq.setLevel(l)}
107
+ class=${l.length > 2 ? "pnx-level-long" : null}
108
+ >
109
+ ${ieq.level == l ? html`<span class="pnx-level-active">${l}</span>`: l}
110
+ </pnx-button>
111
+ `)}
112
+ </pnx-button-group>
113
+ ` : html`
114
+ <pnx-button
115
+ kind="superflat"
116
+ class="pnx-level-minimal"
117
+ title=${this._parent?._t?.pnx.indoor_selector_expand}
118
+ @click=${ieq.levels.length > 1 ? () => this._expanded = true : null}
119
+ >${ieq.level}</pnx-button>
120
+ `}
121
+
122
+ <pnx-button
123
+ kind="superflat"
124
+ @click=${() => ieq.setLevel(lvlDown)}
125
+ .disabled=${lvlDown === null}
126
+ class="pnx-level-minimal"
127
+ title=${this._parent?._t?.pnx.indoor_selector_leveldown}
128
+ >${fa(faCaretDown)}</pnx-button>
129
+
130
+ ${this._expanded ? html`
131
+ <pnx-button
132
+ kind="flat"
133
+ class="pnx-level-shrink"
134
+ @click=${() => this._expanded = false}
135
+ title=${this._parent?._t?.pnx.indoor_selector_shrink}
136
+ >${fa(faTimes)}</pnx-button>
137
+ ` : nothing}
138
+ </pnx-button-group>
139
+ `;
140
+ }
141
+ }
142
+
143
+ customElements.define("pnx-level-select", LevelSelect);
@@ -0,0 +1,114 @@
1
+ import { LitElement, html, nothing } from "lit";
2
+ import { fa, onceParentAvailable } from "../../../utils/widgets.js";
3
+ import {
4
+ faChevronDown, faSliders, faXmark
5
+ } from "@fortawesome/free-solid-svg-icons";
6
+ import { activeIcon } from "../../styles.js";
7
+
8
+ /**
9
+ * Collapsible button showing off map filters menus.
10
+ * @class Panoramax.components.ui.widgets.MapFiltersButton
11
+ * @element pnx-widget-mapfilters
12
+ * @extends [lit.LitElement](https://lit.dev/docs/api/LitElement/)
13
+ * @example
14
+ * ```html
15
+ * <pnx-widget-mapfilters user-search="" _parent=${viewer} />
16
+ * ```
17
+ */
18
+ export default class MapFiltersButton extends LitElement {
19
+ /** @private */
20
+ static styles = [activeIcon];
21
+
22
+ /**
23
+ * Component properties.
24
+ * @memberof Panoramax.components.ui.widgets.MapFiltersButton#
25
+ * @type {Object}
26
+ * @property {boolean} [user-search=false] Should user search filter show up ?
27
+ * @property {boolean} [quality-score=false] Should quality score filter show up ?
28
+ * @property {boolean} [no-date=false] Should date filters be hidden ?
29
+ * @property {boolean} [no-picture-type=false] Should picture type filter be hidden ?
30
+ * @property {boolean} [no-gps=false] Should GPS precision filter be hidden ?
31
+ * @property {boolean} [no-source=false] Should pictures source (world, instance) filter be hidden ?
32
+ */
33
+ static properties = {
34
+ "quality-score": {type: Boolean}, // Should be available in pnx-map-filters-menu as well
35
+ "user-search": {type: Boolean}, // Should be available in pnx-map-filters-menu as well
36
+ "no-date": {type: Boolean}, // Should be available in pnx-map-filters-menu as well
37
+ "no-picture-type": {type: Boolean}, // Should be available in pnx-map-filters-menu as well
38
+ "no-gps": {type: Boolean}, // Should be available in pnx-map-filters-menu as well
39
+ "no-source": {type: Boolean}, // Should be available in pnx-map-filters-menu as well
40
+ _active: {state: true},
41
+ };
42
+
43
+ constructor() {
44
+ super();
45
+
46
+ // Add them in render below as well
47
+ this["user-search"] = false;
48
+ this["quality-score"] = false;
49
+ this["no-date"] = false;
50
+ this["no-picture-type"] = false;
51
+ this["no-gps"] = false;
52
+ this["no-source"] = false;
53
+ this._active = false;
54
+ }
55
+
56
+ /** @private */
57
+ connectedCallback() {
58
+ super.connectedCallback();
59
+
60
+ // Listen to user visibility changes to switch the filter active icon
61
+ onceParentAvailable(this).then(() => this._parent?.onceMapReady?.().then(() => {
62
+ this._active = this._isActive();
63
+ this._parent.mapStyleComposer.addEventListener("filters-changed", () => this._active = this._isActive());
64
+ this._parent.mapStyleComposer.addEventListener("panoramax-changed", () => this._active = this._isActive());
65
+ }));
66
+ }
67
+
68
+ /** @private */
69
+ _isActive() {
70
+ return Object
71
+ .entries(this._parent.mapStyleComposer.panoramaxFilters)
72
+ .filter(([k,v]) => k && v && !["featuresRestrictions", "theme"].includes(k)).length > 0
73
+ || this._parent.mapStyleComposer.isPanoramaxEndpointSingleUser();
74
+ }
75
+
76
+ /** @private */
77
+ render() {
78
+ const isSmall = this._parent?.isWidthSmall() || this._parent?.isWidthMedium();
79
+ const resetIcon = fa(faXmark, {styles: {"pointer-events": "auto"}});
80
+ resetIcon.addEventListener("click", e => {
81
+ e.stopPropagation();
82
+ this.shadowRoot.querySelector("pnx-map-filters-menu")._onReset();
83
+ this.shadowRoot.querySelector("#pnx-widget-filter")._opened = false;
84
+ });
85
+
86
+ return html`
87
+ <pnx-togglable-group
88
+ id="pnx-widget-filter"
89
+ padded="false"
90
+ class="pnx-only-map pnx-print-hidden"
91
+ ._parent=${this._parent}
92
+ >
93
+ <pnx-button kind="flat" size="xl" slot="button">
94
+ ${fa(faSliders)}
95
+ ${this._active ? html`<span class="pnx-active-icon"></span>` : nothing}
96
+ ${isSmall ? nothing : this._parent?._t.pnx.filters}
97
+ ${isSmall ? nothing : (this._active ? resetIcon : fa(faChevronDown))}
98
+ </pnx-button>
99
+ <pnx-map-filters-menu
100
+ id="pnx-map-filters-menu"
101
+ ._parent=${this._parent}
102
+ user-search=${this["user-search"]}
103
+ quality-score=${this["quality-score"]}
104
+ .no-date=${this["no-date"]}
105
+ .no-picture-type=${this["no-picture-type"]}
106
+ .no-gps=${this["no-gps"]}
107
+ .no-source=${this["no-source"]}
108
+ ></pnx-map-filters-menu>
109
+ </pnx-togglable-group>
110
+ `;
111
+ }
112
+ }
113
+
114
+ customElements.define("pnx-widget-mapfilters", MapFiltersButton);
@@ -0,0 +1,79 @@
1
+ import { LitElement, html, nothing } from "lit";
2
+ import { fa, onceParentAvailable } from "../../../utils/widgets.js";
3
+ import {
4
+ faChevronDown, faLayerGroup, faXmark
5
+ } from "@fortawesome/free-solid-svg-icons";
6
+ import { activeIcon } from "../../styles.js";
7
+
8
+ /**
9
+ * Collapsible button showing off map filters menus.
10
+ * @class Panoramax.components.ui.widgets.MapLayersButton
11
+ * @element pnx-widget-maplayers
12
+ * @extends [lit.LitElement](https://lit.dev/docs/api/LitElement/)
13
+ * @example
14
+ * ```html
15
+ * <pnx-widget-maplayers _parent=${viewer} />
16
+ * ```
17
+ */
18
+ export default class MapLayersButton extends LitElement {
19
+ /** @private */
20
+ static styles = [activeIcon];
21
+
22
+ /** @private */
23
+ static properties = {
24
+ _active: {state: true},
25
+ };
26
+
27
+ constructor() {
28
+ super();
29
+ this._active = false;
30
+ }
31
+
32
+ /** @private */
33
+ connectedCallback() {
34
+ super.connectedCallback();
35
+
36
+ const nullThemes = [undefined, null, "", "default"];
37
+
38
+ onceParentAvailable(this).then(() => this._parent?.onceMapReady?.().then(() => {
39
+ this._active = !nullThemes.includes(this._parent.mapStyleComposer.panoramaxTheme);
40
+ this._parent.mapStyleComposer.addEventListener("theme-changed", e => {
41
+ this._active = !nullThemes.includes(e.detail.theme);
42
+ });
43
+ }));
44
+ }
45
+
46
+ /** @private */
47
+ render() {
48
+ const isSmall = this._parent?.isWidthSmall() || this._parent?.isWidthMedium();
49
+ const resetIcon = fa(faXmark, {styles: {"pointer-events": "auto"}});
50
+ resetIcon.addEventListener("click", e => {
51
+ e.stopPropagation();
52
+ const menu = this.shadowRoot.querySelector("pnx-map-layers-menu");
53
+ menu.shadowRoot.querySelector("#pnx-map-theme").value = "default";
54
+ menu._onThemeSelect({target: {value: "default"}});
55
+ this.shadowRoot.querySelector("#pnx-widget-map-layers")._opened = false;
56
+ });
57
+
58
+ return html`
59
+ <pnx-togglable-group
60
+ id="pnx-widget-map-layers"
61
+ class="pnx-print-hidden"
62
+ ._parent=${this._parent}
63
+ >
64
+ <pnx-button kind="flat" size="xl" slot="button">
65
+ ${fa(faLayerGroup)}
66
+ ${this._active ? html`<span class="pnx-active-icon"></span>` : nothing}
67
+ ${isSmall ? nothing : this._parent?._t.pnx.layers}
68
+ ${isSmall ? nothing : (this._active ? resetIcon : fa(faChevronDown))}
69
+ </pnx-button>
70
+ <pnx-map-layers-menu
71
+ id="pnx-map-layers-menu"
72
+ ._parent=${this._parent}
73
+ ></pnx-map-layers-menu>
74
+ </pnx-togglable-group>
75
+ `;
76
+ }
77
+ }
78
+
79
+ customElements.define("pnx-widget-maplayers", MapLayersButton);