@panoramax/web-viewer 4.0.3-develop-b409e7cf → 4.0.3-develop-fc3c6115

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.
@@ -152,6 +152,12 @@ jest.mock("@photo-sphere-viewer/core", () => ({
152
152
  }
153
153
  };
154
154
  this.receivedEvents = [];
155
+ this.container = {
156
+ classList: {
157
+ add: jest.fn(),
158
+ remove: jest.fn(),
159
+ },
160
+ };
155
161
  }
156
162
  addEventListener(t, h) {
157
163
  this.receivedEvents.push([t, h]);
@@ -152,6 +152,8 @@ Filter the visible data content in all visible map layers
152
152
  ### map.displayPictureMarker(lon, lat, heading, [skipCenter], [picId])
153
153
  Shows on map a picture position and heading.
154
154
 
155
+ If no longitude & latitude are set, marker is removed from map.
156
+
155
157
  **Kind**: instance method of [<code>Map</code>](#Panoramax.components.ui.Map)
156
158
 
157
159
  | Param | Type | Default | Description |
@@ -151,6 +151,8 @@ Filter the visible data content in all visible map layers
151
151
  ### mapMore.displayPictureMarker(lon, lat, heading, [skipCenter], [picId])
152
152
  Shows on map a picture position and heading.
153
153
 
154
+ If no longitude & latitude are set, marker is removed from map.
155
+
154
156
  **Kind**: instance method of [<code>MapMore</code>](#Panoramax.components.ui.MapMore)
155
157
 
156
158
  | Param | Type | Default | Description |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoramax/web-viewer",
3
- "version": "4.0.3-develop-b409e7cf",
3
+ "version": "4.0.3-develop-fc3c6115",
4
4
  "description": "Panoramax web viewer for geolocated pictures",
5
5
  "main": "build/index.js",
6
6
  "author": "Panoramax team",
@@ -46,3 +46,10 @@ pnx-photo-viewer pnx-cornered-grid::part(corner-bottom-right) {
46
46
  top: 10px;
47
47
  }
48
48
  }
49
+
50
+ /* Hidden widgets on sequence play */
51
+ pnx-photo-viewer.pnx-playing pnx-bottom-drawer,
52
+ pnx-photo-viewer.pnx-playing pnx-widget-legend,
53
+ pnx-photo-viewer.pnx-playing pnx-widget-zoom {
54
+ display: none;
55
+ }
@@ -327,6 +327,10 @@ export default class PhotoViewer extends Basic {
327
327
  this.loader.setAttribute("value", 50);
328
328
  alterPSVState(this.psv, this._initParams.getPSVPostInit());
329
329
  });
330
+
331
+ // Show class when PSV is playing sequence
332
+ this.psv.addEventListener("sequence-playing", () => this.classList.add("pnx-playing"));
333
+ this.psv.addEventListener("sequence-stopped", () => this.classList.remove("pnx-playing"));
330
334
  }
331
335
  catch(e) {
332
336
  let err = !PSSystem.isWebGLSupported ? this._t.pnx.error_webgl : this._t.pnx.error_psv;
@@ -95,4 +95,12 @@ pnx-viewer .pnx-map .maplibregl-ctrl-attrib {
95
95
  width: 250px;
96
96
  max-width: 40vw;
97
97
  }
98
- }
98
+ }
99
+
100
+ /* Hidden widgets on sequence play */
101
+ pnx-viewer.pnx-playing pnx-bottom-drawer,
102
+ pnx-viewer.pnx-playing pnx-mini,
103
+ pnx-viewer.pnx-playing pnx-widget-legend,
104
+ pnx-viewer.pnx-playing pnx-widget-zoom {
105
+ display: none;
106
+ }
@@ -106,7 +106,6 @@ export default class PictureLegend extends LitElement {
106
106
  pnx-picture-metadata {
107
107
  margin: 5px 10px 10px;
108
108
  display: block;
109
- max-width: 450px;
110
109
  box-sizing: border-box;
111
110
  }
112
111
 
@@ -1,7 +1,7 @@
1
1
  import "./Map.css";
2
2
  import {
3
3
  VECTOR_STYLES, TILES_PICTURES_ZOOM, getThumbGif, RASTER_LAYER_ID, combineStyles,
4
- getMissingLayerStyles, isLabelLayer, getUserLayerId, getUserSourceId,
4
+ getMissingLayerStyles, isLabelLayer, getUserLayerId, getUserSourceId, isNullCoordinates,
5
5
  } from "../../utils/map";
6
6
  import { COLORS } from "../../utils/utils";
7
7
  import MarkerBaseSVG from "../../img/marker.svg";
@@ -206,7 +206,7 @@ export default class Map extends maplibregl.Map {
206
206
  */
207
207
  _initMapPosition() {
208
208
  if(
209
- (!this._options.center || this._options.center == [0,0])
209
+ isNullCoordinates(this._options.center)
210
210
  && (!this._options.zoom || this._options.zoom === 0)
211
211
  && (!this._options.hash)
212
212
  ) {
@@ -417,6 +417,8 @@ export default class Map extends maplibregl.Map {
417
417
 
418
418
  /**
419
419
  * Shows on map a picture position and heading.
420
+ *
421
+ * If no longitude & latitude are set, marker is removed from map.
420
422
  * @memberof Panoramax.components.ui.Map#
421
423
  * @param {number} lon The longitude
422
424
  * @param {number} lat The latitude
@@ -39,6 +39,10 @@
39
39
  filter: drop-shadow(0 0 15px var(--blue));
40
40
  }
41
41
 
42
+ .pnx-psv-playing .pnx-psv-tour-arrows {
43
+ display: none;
44
+ }
45
+
42
46
  /* No virtual tour arrows if photo is reduced */
43
47
  pnx-mini .psv-virtual-tour-arrows {
44
48
  display: none;
@@ -803,6 +803,7 @@ export default class Photo extends PSViewer {
803
803
  */
804
804
  playSequence() {
805
805
  this._sequencePlaying = true;
806
+ this.container.classList.add("pnx-psv-playing");
806
807
 
807
808
  /**
808
809
  * Event for sequence starting to play
@@ -841,6 +842,7 @@ export default class Photo extends PSViewer {
841
842
  */
842
843
  stopSequence() {
843
844
  this._sequencePlaying = false;
845
+ this.container.classList.remove("pnx-psv-playing");
844
846
 
845
847
  // Next picture timer is pending
846
848
  if(this._playTimer) {
@@ -64,7 +64,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
64
64
  let psv_nav = urlParams.nav || componentPsv?.picturesNavigation;
65
65
  let map_theme = urlParams.theme || browserMap?.theme || componentMap.theme;
66
66
  let map_background = urlParams.background || browserMap?.background || componentMap.background;
67
- let map_center = urlMap?.center || browserMap?.center || componentMap.center;
67
+ let map_center = urlMap?.center || (!picture && (browserMap?.center || componentMap.center)) || [0,0];
68
68
  let map_zoom = urlMap?.zoom || browserMap?.zoom || componentMap.zoom;
69
69
  let map_pitch = urlMap?.pitch || componentMap.pitch;
70
70
  let map_bearing = urlMap?.bearing || componentMap.bearing;
package/src/utils/map.js CHANGED
@@ -95,6 +95,17 @@ export function getThumbGif(lang) {
95
95
  return thumbGif;
96
96
  }
97
97
 
98
+ export function isNullCoordinates(c) {
99
+ return (
100
+ c === null
101
+ || c === undefined
102
+ || (Array.isArray(c) && (
103
+ (c.length === 2 && c[0] === 0 && c[1] === 0)
104
+ || c.length < 2
105
+ ))
106
+ );
107
+ }
108
+
98
109
  /**
99
110
  * Is given layer a label layer.
100
111
  *
@@ -413,7 +424,14 @@ export function linkMapAndPhoto(parent) {
413
424
  }
414
425
  }
415
426
  else {
416
- parent.map.displayPictureMarker(e.detail.lon, e.detail.lat, parent.psv.getXY().x, e.detail.first, e.detail.picId);
427
+ parent.map.displayPictureMarker(
428
+ e.detail.lon,
429
+ e.detail.lat,
430
+ parent.psv.getXY().x,
431
+ e.detail.first && !isNullCoordinates(parent._initParams?.getMapPostInit()?.center), // Skip centering if precise coordinates are set from URL
432
+ e.detail.picId
433
+ );
434
+
417
435
  if(parent?.isMapWide?.()) {
418
436
  parent?.mini?.removeAttribute("collapsed");
419
437
  }
@@ -118,6 +118,7 @@ describe("InitParameters", () => {
118
118
 
119
119
  it("uses browserStorage parameters if no URL parameter is available", () => {
120
120
  componentAttrs.map.raster = {};
121
+ componentAttrs.picture = undefined;
121
122
  const initParams = new InitParameters(componentAttrs, undefined, browserStorage);
122
123
  expect(initParams._mapAny).toEqual({
123
124
  theme: "qualityscore",
@@ -130,6 +131,20 @@ describe("InitParameters", () => {
130
131
  });
131
132
  });
132
133
 
134
+ it("uses browserStorage parameters if no URL parameter is available, except map coords if picture is set", () => {
135
+ componentAttrs.map.raster = {};
136
+ const initParams = new InitParameters(componentAttrs, undefined, browserStorage);
137
+ expect(initParams._mapAny).toEqual({
138
+ theme: "qualityscore",
139
+ background: "aerial",
140
+ center: [0,0],
141
+ zoom: 19,
142
+ pitch: undefined,
143
+ bearing: undefined,
144
+ users: "user1,user2",
145
+ });
146
+ });
147
+
133
148
  it("should sanitize objects correctly", () => {
134
149
  const initParams = new InitParameters(componentAttrs, urlParams);
135
150
  const obj = { a: 1, b: undefined, c: 3 };
@@ -11,6 +11,18 @@ describe("getThumbGif", () => {
11
11
  });
12
12
  });
13
13
 
14
+ describe("isNullCoordinates", () => {
15
+ it.each([
16
+ [undefined, true],
17
+ [null, true],
18
+ [[0,0], true],
19
+ [[48.7, -1.5], false],
20
+ [[], true],
21
+ ])("works with %s", (input, expected) => {
22
+ expect(map.isNullCoordinates(input)).toBe(expected);
23
+ });
24
+ });
25
+
14
26
  describe("isLabelLayer", () => {
15
27
  it("works with just text-field", () => {
16
28
  const layer = { type: "symbol", layout: { "text-field": "Label" } };