@panoramax/web-viewer 3.2.3 → 4.0.0-develop-39167b4d
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/.gitlab-ci.yml +13 -6
- package/CHANGELOG.md +53 -1
- package/CODE_OF_CONDUCT.md +1 -1
- package/README.md +1 -1
- package/build/editor.html +10 -1
- package/build/index.css +12 -12
- package/build/index.css.map +1 -1
- package/build/index.html +1 -1
- package/build/index.js +2126 -14
- package/build/index.js.map +1 -1
- package/build/map.html +1 -1
- package/build/photo.html +1 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff2 +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff2 +0 -0
- package/build/viewer.html +12 -1
- package/build/widgets.html +1 -0
- package/config/jest/mocks.js +201 -0
- package/config/paths.js +2 -0
- package/config/webpack.config.js +52 -0
- package/docs/03_URL_settings.md +14 -16
- package/docs/05_Compatibility.md +59 -76
- package/docs/09_Develop.md +46 -11
- package/docs/90_Releases.md +2 -2
- package/docs/images/class_diagram.drawio +60 -45
- package/docs/images/class_diagram.jpg +0 -0
- package/docs/images/screenshot.jpg +0 -0
- package/docs/index.md +135 -0
- package/docs/reference/components/core/Basic.md +196 -0
- package/docs/reference/components/core/CoverageMap.md +210 -0
- package/docs/reference/components/core/Editor.md +224 -0
- package/docs/reference/components/core/PhotoViewer.md +307 -0
- package/docs/reference/components/core/Viewer.md +350 -0
- package/docs/reference/components/layout/BottomDrawer.md +35 -0
- package/docs/reference/components/layout/CorneredGrid.md +29 -0
- package/docs/reference/components/layout/Mini.md +45 -0
- package/docs/reference/components/layout/Tabs.md +45 -0
- package/docs/reference/components/menus/MapBackground.md +32 -0
- package/docs/reference/components/menus/MapFilters.md +15 -0
- package/docs/reference/components/menus/MapLayers.md +15 -0
- package/docs/reference/components/menus/MapLegend.md +15 -0
- package/docs/reference/components/menus/PictureLegend.md +16 -0
- package/docs/reference/components/menus/PictureMetadata.md +15 -0
- package/docs/reference/components/menus/PlayerOptions.md +15 -0
- package/docs/reference/components/menus/QualityScoreDoc.md +15 -0
- package/docs/reference/components/menus/ReportForm.md +15 -0
- package/docs/reference/components/menus/ShareMenu.md +15 -0
- package/docs/reference/components/ui/Button.md +40 -0
- package/docs/reference/components/ui/ButtonGroup.md +36 -0
- package/docs/reference/components/ui/CopyButton.md +38 -0
- package/docs/reference/components/ui/Grade.md +32 -0
- package/docs/reference/components/ui/LinkButton.md +45 -0
- package/docs/reference/components/ui/ListGroup.md +22 -0
- package/docs/reference/components/ui/Loader.md +56 -0
- package/docs/reference/components/ui/Map.md +239 -0
- package/docs/reference/components/ui/MapMore.md +256 -0
- package/docs/reference/components/ui/Photo.md +385 -0
- package/docs/reference/components/ui/Popup.md +56 -0
- package/docs/reference/components/ui/ProgressBar.md +32 -0
- package/docs/reference/components/ui/QualityScore.md +45 -0
- package/docs/reference/components/ui/SearchBar.md +63 -0
- package/docs/reference/components/ui/TogglableGroup.md +39 -0
- package/docs/reference/components/ui/widgets/GeoSearch.md +32 -0
- package/docs/reference/components/ui/widgets/Legend.md +49 -0
- package/docs/reference/components/ui/widgets/MapFiltersButton.md +33 -0
- package/docs/reference/components/ui/widgets/MapLayersButton.md +15 -0
- package/docs/reference/components/ui/widgets/OSMEditors.md +15 -0
- package/docs/reference/components/ui/widgets/PictureLegendActions.md +32 -0
- package/docs/reference/components/ui/widgets/Player.md +33 -0
- package/docs/reference/components/ui/widgets/Zoom.md +15 -0
- package/docs/reference/utils/API.md +334 -0
- package/docs/reference/utils/InitParameters.md +68 -0
- package/docs/reference/utils/URLHandler.md +107 -0
- package/docs/reference.md +79 -0
- package/docs/shortcuts.md +11 -0
- package/docs/tutorials/aerial_imagery.md +19 -0
- package/docs/tutorials/authentication.md +10 -0
- package/docs/tutorials/custom_widgets.md +59 -0
- package/docs/tutorials/map_style.md +39 -0
- package/docs/tutorials/migrate_v4.md +153 -0
- package/docs/tutorials/synced_coverage.md +43 -0
- package/mkdocs.yml +66 -5
- package/package.json +22 -17
- package/public/editor.html +21 -29
- package/public/index.html +17 -12
- package/public/map.html +19 -18
- package/public/photo.html +55 -0
- package/public/viewer.html +22 -26
- package/public/widgets.html +306 -0
- package/scripts/doc.js +79 -0
- package/src/components/core/Basic.css +48 -0
- package/src/components/core/Basic.js +349 -0
- package/src/components/core/CoverageMap.css +9 -0
- package/src/components/core/CoverageMap.js +139 -0
- package/src/components/core/Editor.css +23 -0
- package/src/components/core/Editor.js +390 -0
- package/src/components/core/PhotoViewer.css +48 -0
- package/src/components/core/PhotoViewer.js +499 -0
- package/src/components/core/Viewer.css +98 -0
- package/src/components/core/Viewer.js +564 -0
- package/src/components/core/index.js +12 -0
- package/src/components/index.js +13 -0
- package/src/components/layout/BottomDrawer.js +257 -0
- package/src/components/layout/CorneredGrid.js +112 -0
- package/src/components/layout/Mini.js +117 -0
- package/src/components/layout/Tabs.js +133 -0
- package/src/components/layout/index.js +9 -0
- package/src/components/menus/MapBackground.js +106 -0
- package/src/components/menus/MapFilters.js +400 -0
- package/src/components/menus/MapLayers.js +143 -0
- package/src/components/menus/MapLegend.js +34 -0
- package/src/components/menus/PictureLegend.js +257 -0
- package/src/components/menus/PictureMetadata.js +317 -0
- package/src/components/menus/PlayerOptions.js +95 -0
- package/src/components/menus/QualityScoreDoc.js +36 -0
- package/src/components/menus/ReportForm.js +133 -0
- package/src/components/menus/Share.js +100 -0
- package/src/components/menus/index.js +15 -0
- package/src/components/styles.js +383 -0
- package/src/components/ui/Button.js +77 -0
- package/src/components/ui/ButtonGroup.css +57 -0
- package/src/components/ui/ButtonGroup.js +68 -0
- package/src/components/ui/CopyButton.js +106 -0
- package/src/components/ui/Grade.js +54 -0
- package/src/components/ui/LinkButton.js +67 -0
- package/src/components/ui/ListGroup.js +66 -0
- package/src/components/ui/Loader.js +203 -0
- package/src/components/{Map.css → ui/Map.css} +5 -17
- package/src/components/{Map.js → ui/Map.js} +148 -156
- package/src/components/ui/MapMore.js +324 -0
- package/src/components/{Photo.css → ui/Photo.css} +6 -6
- package/src/components/{Photo.js → ui/Photo.js} +313 -101
- package/src/components/ui/Popup.js +145 -0
- package/src/components/ui/ProgressBar.js +104 -0
- package/src/components/ui/QualityScore.js +147 -0
- package/src/components/ui/SearchBar.js +367 -0
- package/src/components/ui/TogglableGroup.js +157 -0
- package/src/components/ui/index.js +22 -0
- package/src/components/ui/widgets/GeoSearch.css +21 -0
- package/src/components/ui/widgets/GeoSearch.js +139 -0
- package/src/components/ui/widgets/Legend.js +113 -0
- package/src/components/ui/widgets/MapFiltersButton.js +104 -0
- package/src/components/ui/widgets/MapLayersButton.js +79 -0
- package/src/components/ui/widgets/OSMEditors.js +155 -0
- package/src/components/ui/widgets/PictureLegendActions.js +117 -0
- package/src/components/ui/widgets/Player.css +7 -0
- package/src/components/ui/widgets/Player.js +151 -0
- package/src/components/ui/widgets/Zoom.js +82 -0
- package/src/components/ui/widgets/index.js +13 -0
- package/src/img/loader_base.jpg +0 -0
- package/src/img/panoramax.svg +13 -0
- package/src/img/switch_big.svg +20 -10
- package/src/index.js +7 -9
- package/src/translations/br.json +1 -0
- package/src/translations/da.json +38 -15
- package/src/translations/de.json +5 -3
- package/src/translations/en.json +35 -15
- package/src/translations/eo.json +38 -15
- package/src/translations/es.json +1 -1
- package/src/translations/fr.json +36 -16
- package/src/translations/hu.json +1 -1
- package/src/translations/it.json +39 -16
- package/src/translations/ja.json +182 -1
- package/src/translations/nl.json +106 -6
- package/src/translations/pl.json +1 -1
- package/src/translations/sv.json +182 -0
- package/src/translations/zh_Hant.json +35 -14
- package/src/utils/API.js +109 -49
- package/src/utils/InitParameters.js +388 -0
- package/src/utils/PhotoAdapter.js +1 -0
- package/src/utils/URLHandler.js +362 -0
- package/src/utils/geocoder.js +152 -0
- package/src/utils/{I18n.js → i18n.js} +7 -3
- package/src/utils/index.js +11 -0
- package/src/utils/{Map.js → map.js} +256 -77
- package/src/utils/picture.js +442 -0
- package/src/utils/utils.js +324 -0
- package/src/utils/widgets.js +55 -0
- package/tests/components/core/Basic.test.js +121 -0
- package/tests/components/core/BasicMock.js +25 -0
- package/tests/components/core/CoverageMap.test.js +20 -0
- package/tests/components/core/Editor.test.js +20 -0
- package/tests/components/core/PhotoViewer.test.js +57 -0
- package/tests/components/core/Viewer.test.js +84 -0
- package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +73 -0
- package/tests/components/core/__snapshots__/Viewer.test.js.snap +145 -0
- package/tests/components/ui/CopyButton.test.js +52 -0
- package/tests/components/ui/Loader.test.js +55 -0
- package/tests/components/{Map.test.js → ui/Map.test.js} +73 -61
- package/tests/components/{Photo.test.js → ui/Photo.test.js} +97 -63
- package/tests/components/ui/Popup.test.js +26 -0
- package/tests/components/ui/QualityScore.test.js +18 -0
- package/tests/components/ui/SearchBar.test.js +110 -0
- package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +33 -0
- package/tests/components/ui/__snapshots__/Loader.test.js.snap +56 -0
- package/tests/components/{__snapshots__ → ui/__snapshots__}/Map.test.js.snap +11 -38
- package/tests/components/{__snapshots__ → ui/__snapshots__}/Photo.test.js.snap +70 -6
- package/tests/components/ui/__snapshots__/Popup.test.js.snap +29 -0
- package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +11 -0
- package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +65 -0
- package/tests/utils/API.test.js +83 -83
- package/tests/utils/InitParameters.test.js +499 -0
- package/tests/utils/URLHandler.test.js +401 -0
- package/tests/utils/__snapshots__/API.test.js.snap +10 -0
- package/tests/utils/__snapshots__/URLHandler.test.js.snap +21 -0
- package/tests/utils/__snapshots__/{Map.test.js.snap → geocoder.test.js.snap} +1 -1
- package/tests/utils/__snapshots__/map.test.js.snap +11 -0
- package/tests/utils/__snapshots__/picture.test.js.snap +327 -0
- package/tests/utils/__snapshots__/widgets.test.js.snap +19 -0
- package/tests/utils/geocoder.test.js +37 -0
- package/tests/utils/{I18n.test.js → i18n.test.js} +8 -8
- package/tests/utils/map.test.js +126 -0
- package/tests/utils/picture.test.js +745 -0
- package/tests/utils/utils.test.js +288 -0
- package/tests/utils/widgets.test.js +31 -0
- package/docs/01_Start.md +0 -149
- package/docs/02_Usage.md +0 -831
- package/docs/04_Advanced_examples.md +0 -216
- package/src/Editor.css +0 -37
- package/src/Editor.js +0 -361
- package/src/StandaloneMap.js +0 -114
- package/src/Viewer.css +0 -203
- package/src/Viewer.js +0 -1246
- package/src/components/CoreView.css +0 -70
- package/src/components/CoreView.js +0 -175
- package/src/components/Loader.css +0 -74
- package/src/components/Loader.js +0 -120
- package/src/img/loader_hd.jpg +0 -0
- package/src/utils/Exif.js +0 -193
- package/src/utils/Utils.js +0 -631
- package/src/utils/Widgets.js +0 -562
- package/src/viewer/URLHash.js +0 -469
- package/src/viewer/Widgets.css +0 -880
- package/src/viewer/Widgets.js +0 -1470
- package/tests/Editor.test.js +0 -126
- package/tests/StandaloneMap.test.js +0 -45
- package/tests/Viewer.test.js +0 -366
- package/tests/__snapshots__/Editor.test.js.snap +0 -298
- package/tests/__snapshots__/StandaloneMap.test.js.snap +0 -30
- package/tests/__snapshots__/Viewer.test.js.snap +0 -195
- package/tests/components/CoreView.test.js +0 -92
- package/tests/components/Loader.test.js +0 -38
- package/tests/components/__snapshots__/Loader.test.js.snap +0 -15
- package/tests/utils/Exif.test.js +0 -124
- package/tests/utils/Map.test.js +0 -113
- package/tests/utils/Utils.test.js +0 -300
- package/tests/utils/Widgets.test.js +0 -107
- package/tests/utils/__snapshots__/Exif.test.js.snap +0 -43
- package/tests/utils/__snapshots__/Utils.test.js.snap +0 -41
- package/tests/utils/__snapshots__/Widgets.test.js.snap +0 -44
- package/tests/viewer/URLHash.test.js +0 -559
- package/tests/viewer/Widgets.test.js +0 -127
- package/tests/viewer/__snapshots__/URLHash.test.js.snap +0 -108
- package/tests/viewer/__snapshots__/Widgets.test.js.snap +0 -403
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// DO NOT REMOVE THE "!": bundled builds breaks otherwise !!!
|
|
2
|
-
import maplibregl from "!maplibre-gl";
|
|
3
1
|
import LoaderImg from "../img/marker.svg";
|
|
4
|
-
import { COLORS, QUALITYSCORE_RES_FLAT_VALUES, QUALITYSCORE_RES_360_VALUES, QUALITYSCORE_GPS_VALUES, QUALITYSCORE_POND_RES, QUALITYSCORE_POND_GPS } from "./
|
|
5
|
-
import { autoDetectLocale } from "./
|
|
2
|
+
import { COLORS, QUALITYSCORE_RES_FLAT_VALUES, QUALITYSCORE_RES_360_VALUES, QUALITYSCORE_GPS_VALUES, QUALITYSCORE_POND_RES, QUALITYSCORE_POND_GPS } from "./utils";
|
|
3
|
+
import { autoDetectLocale } from "./i18n";
|
|
4
|
+
import { isNullId } from "./utils";
|
|
6
5
|
|
|
7
6
|
export const DEFAULT_TILES = "https://panoramax.openstreetmap.fr/pmtiles/basic.json";
|
|
8
|
-
export const RASTER_LAYER_ID = "
|
|
7
|
+
export const RASTER_LAYER_ID = "pnx-aerial";
|
|
9
8
|
|
|
10
9
|
export const TILES_PICTURES_ZOOM = 15;
|
|
11
10
|
export const TILES_PICTURES_SYMBOL_ZOOM = 18;
|
|
@@ -37,7 +36,7 @@ export const VECTOR_STYLES = {
|
|
|
37
36
|
"icon-opacity": ["interpolate", ["linear"], ["zoom"], TILES_PICTURES_SYMBOL_ZOOM, 0, TILES_PICTURES_SYMBOL_ZOOM+1, 1],
|
|
38
37
|
},
|
|
39
38
|
"layout": {
|
|
40
|
-
"icon-image": ["case", ["==", ["get", "type"], "equirectangular"], "
|
|
39
|
+
"icon-image": ["case", ["==", ["get", "type"], "equirectangular"], "pnx-arrow-360", "pnx-arrow-flat"],
|
|
41
40
|
"icon-size": ["interpolate", ["linear"], ["zoom"], TILES_PICTURES_SYMBOL_ZOOM, 0.5, 24, 1],
|
|
42
41
|
"icon-rotate": ["to-number", ["get", "heading"]],
|
|
43
42
|
"icon-allow-overlap": true,
|
|
@@ -92,7 +91,7 @@ export function getThumbGif(lang) {
|
|
|
92
91
|
thumbGif.src = LoaderImg;
|
|
93
92
|
thumbGif.alt = lang.loading;
|
|
94
93
|
thumbGif.title = lang.loading;
|
|
95
|
-
thumbGif.classList.add("
|
|
94
|
+
thumbGif.classList.add("pnx-map-thumb", "pnx-map-thumb-loader");
|
|
96
95
|
return thumbGif;
|
|
97
96
|
}
|
|
98
97
|
|
|
@@ -106,7 +105,7 @@ export function getThumbGif(lang) {
|
|
|
106
105
|
*/
|
|
107
106
|
export function isLabelLayer(l) {
|
|
108
107
|
return l.type === "symbol"
|
|
109
|
-
&& l?.layout?.["text-field"]
|
|
108
|
+
&& l?.layout?.["text-field"] !== undefined
|
|
110
109
|
&& (l.minzoom === undefined || l.minzoom < 15);
|
|
111
110
|
}
|
|
112
111
|
|
|
@@ -123,9 +122,10 @@ export function isLabelLayer(l) {
|
|
|
123
122
|
*/
|
|
124
123
|
export function combineStyles(parent, options) {
|
|
125
124
|
// Get basic vector styles
|
|
126
|
-
const style = parent.
|
|
125
|
+
const style = parent.api.getMapStyle();
|
|
127
126
|
|
|
128
127
|
// Complete styles
|
|
128
|
+
style.layers = style.layers || [];
|
|
129
129
|
style.layers = style.layers.concat(getMissingLayerStyles(style.sources, style.layers));
|
|
130
130
|
if(!style.metadata) { style.metadata = {}; }
|
|
131
131
|
|
|
@@ -136,13 +136,16 @@ export function combineStyles(parent, options) {
|
|
|
136
136
|
style.layers = style.layers.concat(options.supplementaryStyle.layers || []);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
// Fix for empty layers causing sorting issues
|
|
140
|
+
style.layers = style.layers.filter(l => l.id);
|
|
141
|
+
|
|
139
142
|
// Aerial imagery background
|
|
140
143
|
if(options.raster) {
|
|
141
|
-
style.sources["
|
|
144
|
+
style.sources["pnx-aerial"] = options.raster;
|
|
142
145
|
style.layers.push({
|
|
143
146
|
"id": RASTER_LAYER_ID,
|
|
144
147
|
"type": "raster",
|
|
145
|
-
"source": "
|
|
148
|
+
"source": "pnx-aerial",
|
|
146
149
|
"layout": {
|
|
147
150
|
"visibility": options.background === "aerial" ? "visible" : "none",
|
|
148
151
|
}
|
|
@@ -150,7 +153,7 @@ export function combineStyles(parent, options) {
|
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
// Filter out general tiles if necessary
|
|
153
|
-
if(!parent
|
|
156
|
+
if(!parent?.users?.includes("geovisio")) {
|
|
154
157
|
style.layers.forEach(l => {
|
|
155
158
|
if(l.source === "geovisio") {
|
|
156
159
|
if(!l.layout) { l.layout = {}; }
|
|
@@ -181,7 +184,7 @@ export function combineStyles(parent, options) {
|
|
|
181
184
|
|
|
182
185
|
// Override labels to use appropriate language
|
|
183
186
|
if(style.metadata["panoramax:locales"]) {
|
|
184
|
-
let prefLang = parent.
|
|
187
|
+
let prefLang = parent.lang || autoDetectLocale(style.metadata["panoramax:locales"], "latin");
|
|
185
188
|
if(prefLang.includes("-")) { prefLang = prefLang.split("-")[0]; }
|
|
186
189
|
if(prefLang.includes("_")) { prefLang = prefLang.split("_")[0]; }
|
|
187
190
|
style.layers.forEach(l => {
|
|
@@ -226,11 +229,11 @@ export function combineStyles(parent, options) {
|
|
|
226
229
|
* which didn't offer a MapLibre JSON style directly.
|
|
227
230
|
*
|
|
228
231
|
* @param {object} sources Pre-existing MapLibre style sources
|
|
229
|
-
* @param {object} layers Pre-existing MapLibre style layers
|
|
232
|
+
* @param {object[]} layers Pre-existing MapLibre style layers
|
|
230
233
|
* @returns List of layers to add
|
|
231
234
|
* @private
|
|
232
235
|
*/
|
|
233
|
-
export function getMissingLayerStyles(sources, layers) {
|
|
236
|
+
export function getMissingLayerStyles(sources = {}, layers = []) {
|
|
234
237
|
const newLayers = [];
|
|
235
238
|
|
|
236
239
|
// GeoVisio API <= 2.5.0 : add sequences + pictures
|
|
@@ -389,81 +392,257 @@ export function switchCoefValue(expr, newCoefVal) {
|
|
|
389
392
|
}
|
|
390
393
|
|
|
391
394
|
/**
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
* @param {
|
|
396
|
-
* @return {string} The URL query part
|
|
395
|
+
* Creates links between map and photo elements.
|
|
396
|
+
* This enable interactions like click on map showing picture.
|
|
397
|
+
*
|
|
398
|
+
* @param {CoreView} parent The view containing both Photo and Map elements
|
|
397
399
|
* @private
|
|
398
400
|
*/
|
|
399
|
-
export function
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
export function linkMapAndPhoto(parent) {
|
|
402
|
+
// Switched picture
|
|
403
|
+
const onPicLoad = e => {
|
|
404
|
+
if(isNullId(e.detail.picId)) {
|
|
405
|
+
parent.map.displayPictureMarker();
|
|
406
|
+
if(parent?.isMapWide?.()) {
|
|
407
|
+
parent?.mini?.setAttribute("collapsed", "");
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
parent.map.displayPictureMarker(e.detail.lon, e.detail.lat, parent.psv.getXY().x, e.detail.first);
|
|
412
|
+
if(parent?.isMapWide?.()) {
|
|
413
|
+
parent?.mini?.removeAttribute("collapsed");
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
parent.psv.addEventListener("picture-loading", onPicLoad);
|
|
418
|
+
parent.psv.addEventListener("picture-loaded", onPicLoad);
|
|
419
|
+
|
|
420
|
+
// Picture view rotated
|
|
421
|
+
parent.psv.addEventListener("view-rotated", () => {
|
|
422
|
+
let x = parent.psv.getPosition().yaw * (180 / Math.PI);
|
|
423
|
+
x += parent.psv.getPictureOriginalHeading();
|
|
424
|
+
parent.map._picMarker.setRotation(x);
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// Picture preview
|
|
428
|
+
parent.psv.addEventListener("picture-preview-started", e => {
|
|
429
|
+
// Show marker corresponding to selection
|
|
430
|
+
parent.map._picMarkerPreview
|
|
431
|
+
.setLngLat(e.detail.coordinates)
|
|
432
|
+
.setRotation(e.detail.direction || 0)
|
|
433
|
+
.addTo(parent.map);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
parent.psv.addEventListener("picture-preview-stopped", () => {
|
|
437
|
+
parent.map._picMarkerPreview.remove();
|
|
438
|
+
});
|
|
404
439
|
|
|
405
|
-
|
|
440
|
+
parent.psv.addEventListener("picture-loaded", e => {
|
|
441
|
+
if (parent.isWidthSmall() && parent._picPopup && e.detail.picId == parent._picPopup._picId) {
|
|
442
|
+
parent._picPopup.remove();
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// Picture click
|
|
447
|
+
parent.map.on("picture-click", e => {
|
|
448
|
+
parent.select(e.seqId, e.picId);
|
|
449
|
+
if(!parent.psv._myVTour.state.currentNode && parent?._setFocus) { parent._setFocus("pic"); }
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// Sequence click
|
|
453
|
+
parent.map.on("sequence-click", e => {
|
|
454
|
+
parent.api.getPicturesAroundCoordinates(
|
|
455
|
+
e.coordinates.lat,
|
|
456
|
+
e.coordinates.lng,
|
|
457
|
+
1,
|
|
458
|
+
1,
|
|
459
|
+
e.seqId
|
|
460
|
+
).then(results => {
|
|
461
|
+
if(results?.features?.length > 0) {
|
|
462
|
+
parent.select(results.features[0]?.collection, results.features[0].id);
|
|
463
|
+
if(!parent.psv.getPictureMetadata() && parent?._setFocus) { parent._setFocus("pic"); }
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Focus changes
|
|
469
|
+
if(parent._setFocus) {
|
|
470
|
+
// PSV double click
|
|
471
|
+
parent.psv.addEventListener("dblclick", () => { if(parent.isMapWide()) { parent._setFocus("pic"); } });
|
|
472
|
+
|
|
473
|
+
// Map double-click: unselect if focused, toggle focus if unfocused
|
|
474
|
+
parent.map.on("dblclick", () => {
|
|
475
|
+
if(!parent.isMapWide()) { parent._setFocus("map"); }
|
|
476
|
+
else { parent.select(); }
|
|
477
|
+
});
|
|
478
|
+
}
|
|
406
479
|
}
|
|
407
480
|
|
|
408
481
|
/**
|
|
409
|
-
*
|
|
482
|
+
* Adds events related to keyboard
|
|
410
483
|
* @private
|
|
411
484
|
*/
|
|
412
|
-
export function
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
485
|
+
export function initMapKeyboardHandler(parent) {
|
|
486
|
+
parent.map.keyboard.keydown = function(e) {
|
|
487
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
488
|
+
|
|
489
|
+
// Custom keys
|
|
490
|
+
switch(e.key) {
|
|
491
|
+
case "*":
|
|
492
|
+
case "5":
|
|
493
|
+
parent.moveCenter();
|
|
494
|
+
return;
|
|
495
|
+
|
|
496
|
+
case "PageUp":
|
|
497
|
+
case "9":
|
|
498
|
+
parent.psv.goToNextPicture();
|
|
499
|
+
return;
|
|
500
|
+
|
|
501
|
+
case "PageDown":
|
|
502
|
+
case "3":
|
|
503
|
+
parent.psv.goToPrevPicture();
|
|
504
|
+
return;
|
|
505
|
+
|
|
506
|
+
case "Home":
|
|
507
|
+
case "7":
|
|
508
|
+
e.stopPropagation();
|
|
509
|
+
parent._toggleFocus();
|
|
510
|
+
return;
|
|
511
|
+
|
|
512
|
+
case "End":
|
|
513
|
+
case "1":
|
|
514
|
+
parent.mini.toggleAttribute("collapsed");
|
|
515
|
+
return;
|
|
516
|
+
|
|
517
|
+
case " ":
|
|
518
|
+
case "0":
|
|
519
|
+
parent.psv.toggleSequencePlaying();
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
420
522
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
523
|
+
let zoomDir = 0;
|
|
524
|
+
let bearingDir = 0;
|
|
525
|
+
let pitchDir = 0;
|
|
526
|
+
let xDir = 0;
|
|
527
|
+
let yDir = 0;
|
|
528
|
+
|
|
529
|
+
switch (e.keyCode) {
|
|
530
|
+
case 61:
|
|
531
|
+
case 107:
|
|
532
|
+
case 171:
|
|
533
|
+
case 187:
|
|
534
|
+
zoomDir = 1;
|
|
535
|
+
break;
|
|
536
|
+
|
|
537
|
+
case 189:
|
|
538
|
+
case 109:
|
|
539
|
+
case 173:
|
|
540
|
+
zoomDir = -1;
|
|
541
|
+
break;
|
|
542
|
+
|
|
543
|
+
case 37:
|
|
544
|
+
case 100:
|
|
545
|
+
if (e.shiftKey) {
|
|
546
|
+
bearingDir = -1;
|
|
547
|
+
} else {
|
|
548
|
+
e.preventDefault();
|
|
549
|
+
xDir = -1;
|
|
550
|
+
}
|
|
551
|
+
break;
|
|
552
|
+
|
|
553
|
+
case 39:
|
|
554
|
+
case 102:
|
|
555
|
+
if (e.shiftKey) {
|
|
556
|
+
bearingDir = 1;
|
|
557
|
+
} else {
|
|
558
|
+
e.preventDefault();
|
|
559
|
+
xDir = 1;
|
|
560
|
+
}
|
|
561
|
+
break;
|
|
562
|
+
|
|
563
|
+
case 38:
|
|
564
|
+
case 104:
|
|
565
|
+
if (e.shiftKey) {
|
|
566
|
+
pitchDir = 1;
|
|
567
|
+
} else {
|
|
568
|
+
e.preventDefault();
|
|
569
|
+
yDir = -1;
|
|
570
|
+
}
|
|
571
|
+
break;
|
|
572
|
+
|
|
573
|
+
case 40:
|
|
574
|
+
case 98:
|
|
575
|
+
if (e.shiftKey) {
|
|
576
|
+
pitchDir = -1;
|
|
577
|
+
} else {
|
|
578
|
+
e.preventDefault();
|
|
579
|
+
yDir = 1;
|
|
580
|
+
}
|
|
581
|
+
break;
|
|
582
|
+
|
|
583
|
+
default:
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (this._rotationDisabled) {
|
|
588
|
+
bearingDir = 0;
|
|
589
|
+
pitchDir = 0;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
return {
|
|
593
|
+
cameraAnimation: (map) => {
|
|
594
|
+
const tr = this._tr;
|
|
595
|
+
map.easeTo({
|
|
596
|
+
duration: 300,
|
|
597
|
+
easeId: "keyboardHandler",
|
|
598
|
+
easing: t => t * (2-t),
|
|
599
|
+
zoom: zoomDir ? Math.round(tr.zoom) + zoomDir * (e.shiftKey ? 2 : 1) : tr.zoom,
|
|
600
|
+
bearing: tr.bearing + bearingDir * this._bearingStep,
|
|
601
|
+
pitch: tr.pitch + pitchDir * this._pitchStep,
|
|
602
|
+
offset: [-xDir * this._panStep, -yDir * this._panStep],
|
|
603
|
+
center: tr.center
|
|
604
|
+
}, {originalEvent: e});
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}.bind(parent.map.keyboard);
|
|
438
608
|
}
|
|
439
609
|
|
|
610
|
+
const MAP_PARAMS_STORAGE = "pnx-map-parameters";
|
|
611
|
+
|
|
440
612
|
/**
|
|
441
|
-
*
|
|
442
|
-
* @param {object} config Configuration sent by MapLibre GL Geocoder, following the geocoderApi format ( https://github.com/maplibre/maplibre-gl-geocoder/blob/main/API.md#setgeocoderapi )
|
|
443
|
-
* @returns {object} GeoJSON Feature collection in Carmen GeoJSON format
|
|
613
|
+
* Reads map parameters from localStorage
|
|
444
614
|
* @private
|
|
445
615
|
*/
|
|
446
|
-
export function
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
616
|
+
export function getMapParamsFromLocalStorage() {
|
|
617
|
+
const params = localStorage.getItem(MAP_PARAMS_STORAGE);
|
|
618
|
+
if(!params) { return {}; }
|
|
619
|
+
try {
|
|
620
|
+
return JSON.parse(params);
|
|
621
|
+
}
|
|
622
|
+
catch(e) {
|
|
623
|
+
console.warn("Can't read map parameters stored in localStorage", e);
|
|
624
|
+
return {};
|
|
453
625
|
}
|
|
626
|
+
}
|
|
454
627
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
628
|
+
/**
|
|
629
|
+
* Save map parameters into localStorage.
|
|
630
|
+
* @private
|
|
631
|
+
*/
|
|
632
|
+
export function saveMapParamsToLocalStorage(map) {
|
|
633
|
+
// Save map state in localStorage
|
|
634
|
+
const save = () => localStorage.setItem(MAP_PARAMS_STORAGE, JSON.stringify({
|
|
635
|
+
center: Object.fromEntries(Object.entries(map.getCenter()).map(([k,v]) => ([k,v.toFixed(7)]))),
|
|
636
|
+
zoom: map.getZoom().toFixed(1),
|
|
637
|
+
background: map.getBackground(),
|
|
638
|
+
theme: map._mapFilters.theme
|
|
639
|
+
}));
|
|
640
|
+
|
|
641
|
+
// Add events to know when to rewrite info
|
|
642
|
+
map.on("background-changed", save);
|
|
643
|
+
map.on("filters-changed", save);
|
|
644
|
+
map.on("moveend", save);
|
|
645
|
+
map.on("zoomend", save);
|
|
646
|
+
map.on("dragend", save);
|
|
647
|
+
map.on("boxzoomend", save);
|
|
648
|
+
}
|