@panoramax/web-viewer 3.2.3-develop-d0806c5a → 3.2.3-develop-eb68a0ea
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/build/index.js +4 -4
- package/build/index.js.map +1 -1
- package/docs/09_Develop.md +16 -0
- package/docs/reference/components/core/Viewer.md +8 -2
- package/docs/reference/components/ui/Map.md +1 -0
- package/docs/tutorials/map_style.md +12 -0
- package/docs/tutorials/migrate_v4.md +4 -0
- package/package.json +1 -1
- package/src/components/core/Viewer.js +8 -2
- package/src/components/menus/MapLegend.js +1 -1
- package/src/components/ui/Map.js +6 -3
- package/src/utils/InitParameters.js +2 -2
package/docs/09_Develop.md
CHANGED
|
@@ -38,6 +38,22 @@ In order to offer a coherent overlay of widgets, we follow this general `z-index
|
|
|
38
38
|
| Togglable menus | 130 |
|
|
39
39
|
| Fullscreen loaders & popups | 200 |
|
|
40
40
|
|
|
41
|
+
### Parameters handling
|
|
42
|
+
|
|
43
|
+
!!! note
|
|
44
|
+
|
|
45
|
+
This concerns only __Viewer__ component. Editor & Coverage Map read input parameters only from Web Components attributes.
|
|
46
|
+
|
|
47
|
+
Viewer component can read parameters from 3 different sources:
|
|
48
|
+
|
|
49
|
+
- Web Component __attributes__, passed through DOM
|
|
50
|
+
- Browser __local storage__
|
|
51
|
+
- __URL search__ parameters
|
|
52
|
+
|
|
53
|
+
This allows a flexible way to interact with viewer for users. Prioritization of parameters is managed by [InitParameters class](./reference/utils/InitParameters.md), URL parameters coming first, then local storage, to fallback with Web component attributes (and eventually some hard-coded defaults).
|
|
54
|
+
|
|
55
|
+
This means that, when developing, if you want to check if your attributes are well-defined, you may want to get rid of URL search parameters, as well as remove the `pnx-map-parameters` local storage item. Otherwise, they may not be read as they are lower priority than others.
|
|
56
|
+
|
|
41
57
|
## Testing
|
|
42
58
|
|
|
43
59
|
We're trying to make Panoramax as reliable and secure as possible. To ensure this, we rely heavily on code testing. A variety of testing tools is made available:
|
|
@@ -79,6 +79,12 @@ This component has a [CorneredGrid](../layout/CorneredGrid.md/#Panoramax.compone
|
|
|
79
79
|
>
|
|
80
80
|
<p slot="top-right">My custom text</p>
|
|
81
81
|
</pnx-viewer>
|
|
82
|
+
|
|
83
|
+
<!-- With map options -->
|
|
84
|
+
<pnx-viewer
|
|
85
|
+
endpoint="https://panoramax.openstreetmap.fr/"
|
|
86
|
+
map="{'maxZoom': 15, 'background': 'aerial', 'raster': '...'}"
|
|
87
|
+
/>
|
|
82
88
|
```
|
|
83
89
|
<a name="Panoramax.components.core.Viewer+properties"></a>
|
|
84
90
|
|
|
@@ -92,8 +98,8 @@ Component properties. All of [Basic properties](Basic.md/#Panoramax.components.c
|
|
|
92
98
|
|
|
93
99
|
| Name | Type | Default | Description |
|
|
94
100
|
| --- | --- | --- | --- |
|
|
95
|
-
| [map] | <code>boolean</code> \| <code>object</code> | <code>true</code> | Should map be used (true/false), or an object with [any map option available in Map class](../ui/MapMore.md/#Panoramax.components.ui.MapMore) |
|
|
96
|
-
| [psv] | <code>object</code> | | [Any option to pass to Photo component](../ui/Photo.md/#Panoramax.components.ui.Photo) as an object |
|
|
101
|
+
| [map] | <code>boolean</code> \| <code>object</code> | <code>true</code> | Should map be used (true/false), or an object with [any map option available in Map or MapMore class](../ui/MapMore.md/#Panoramax.components.ui.MapMore).<br />Example: `map="{'background': 'aerial', 'theme': 'age'}"` |
|
|
102
|
+
| [psv] | <code>object</code> | | [Any option to pass to Photo component](../ui/Photo.md/#Panoramax.components.ui.Photo) as an object.<br />Example: `psv="{'transitionDuration': 500, 'picturesNavigation': 'pic'}"` |
|
|
97
103
|
| [url-parameters] | <code>string</code> | <code>true</code> | Should the component add and update URL query parameters to save viewer state ? |
|
|
98
104
|
| [focus] | <code>string</code> | <code>"pic"</code> | The component showing up as main component (pic, map) |
|
|
99
105
|
| [geocoder] | <code>string</code> | <code>"nominatim"</code> | The geocoder engine to use (nominatim, ban) |
|
|
@@ -45,6 +45,7 @@ It uses instead [`on`](https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/
|
|
|
45
45
|
| [options] | <code>object</code> | | The map options (any of [MapLibre GL settings](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions/) or any supplementary option defined here) |
|
|
46
46
|
| [options.raster] | <code>object</code> | | The MapLibre raster source for aerial background. This must be a JSON object following [MapLibre raster source definition](https://maplibre.org/maplibre-style-spec/sources/#raster). |
|
|
47
47
|
| [options.background] | <code>string</code> | <code>"streets"</code> | Choose default map background to display (streets or aerial, if raster aerial background available). Defaults to street. |
|
|
48
|
+
| [options.attributionControl.customAttribution] | <code>string</code> | | To override default map attribution. |
|
|
48
49
|
|
|
49
50
|
**Example**
|
|
50
51
|
```js
|
|
@@ -25,3 +25,15 @@ Note that we also support PMTiles (for a simpler tile hosting), so your style fi
|
|
|
25
25
|
}'
|
|
26
26
|
/>
|
|
27
27
|
```
|
|
28
|
+
|
|
29
|
+
And you can also customize the map attribution, especially if your style JSON doesn't contain any by default, for example:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<pnx-viewer
|
|
33
|
+
endpoint="https://api.panoramax.xyz/api"
|
|
34
|
+
mapstyle="https://my.tiles.provider/basic.json"
|
|
35
|
+
map='{
|
|
36
|
+
"attributionControl": { "customAttribution": "© IGN" }
|
|
37
|
+
}'
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
@@ -132,3 +132,7 @@ URL parameters are now managed in the URL _search_ part (everything after the `?
|
|
|
132
132
|
```urlencoded
|
|
133
133
|
https://panoramax.ign.fr/?background=streets&focus=map&map=9/48.6659/2.3237&speed=250
|
|
134
134
|
```
|
|
135
|
+
|
|
136
|
+
## 🪛 Initialization parameters
|
|
137
|
+
|
|
138
|
+
Parameters passed to __Viewer__ are more finely read, they can come from Web Component itself (attributes), browser local storage or URL search parameters. URL ones are read first, then local storage, and finally component attributes. This can be misleading while you develop, [read more about this on Develop documentation](../09_Develop.md#parameters-handling).
|
package/package.json
CHANGED
|
@@ -69,6 +69,12 @@ const MAP_MOVE_DELTA = 100;
|
|
|
69
69
|
* >
|
|
70
70
|
* <p slot="top-right">My custom text</p>
|
|
71
71
|
* </pnx-viewer>
|
|
72
|
+
*
|
|
73
|
+
* <!-- With map options -->
|
|
74
|
+
* <pnx-viewer
|
|
75
|
+
* endpoint="https://panoramax.openstreetmap.fr/"
|
|
76
|
+
* map="{'maxZoom': 15, 'background': 'aerial', 'raster': '...'}"
|
|
77
|
+
* />
|
|
72
78
|
* ```
|
|
73
79
|
*/
|
|
74
80
|
export default class Viewer extends Basic {
|
|
@@ -77,8 +83,8 @@ export default class Viewer extends Basic {
|
|
|
77
83
|
* @memberof Panoramax.components.core.Viewer#
|
|
78
84
|
* @mixes Panoramax.components.core.Basic#properties
|
|
79
85
|
* @type {Object}
|
|
80
|
-
* @property {boolean|object} [map=true] Should map be used (true/false), or an object with [any map option available in Map class](#Panoramax.components.ui.MapMore)
|
|
81
|
-
* @property {object} [psv] [Any option to pass to Photo component](#Panoramax.components.ui.Photo) as an object
|
|
86
|
+
* @property {boolean|object} [map=true] Should map be used (true/false), or an object with [any map option available in Map or MapMore class](#Panoramax.components.ui.MapMore).<br />Example: `map="{'background': 'aerial', 'theme': 'age'}"`
|
|
87
|
+
* @property {object} [psv] [Any option to pass to Photo component](#Panoramax.components.ui.Photo) as an object.<br />Example: `psv="{'transitionDuration': 500, 'picturesNavigation': 'pic'}"`
|
|
82
88
|
* @property {string} [url-parameters=true] Should the component add and update URL query parameters to save viewer state ?
|
|
83
89
|
* @property {string} [focus=pic] The component showing up as main component (pic, map)
|
|
84
90
|
* @property {string} [geocoder=nominatim] The geocoder engine to use (nominatim, ban)
|
|
@@ -46,7 +46,7 @@ export default class MapLegend extends LitElement {
|
|
|
46
46
|
</pnx-link-button>
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
49
|
-
${mapAttrib ? html`${this._parent?._t.map.map_data}<br />${mapAttrib}` : nothing}
|
|
49
|
+
${mapAttrib && mapAttrib.innerHTML.length > 0 ? html`${this._parent?._t.map.map_data}<br />${mapAttrib}` : nothing}
|
|
50
50
|
`;
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/components/ui/Map.js
CHANGED
|
@@ -17,8 +17,10 @@ import * as pmtiles from "pmtiles";
|
|
|
17
17
|
maplibregl.workerClass = maplibreglWorker;
|
|
18
18
|
maplibregl.addProtocol("pmtiles", new pmtiles.Protocol().tile);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// No "style" option as it's handled by combineStyles function
|
|
21
|
+
// and no "attributionControl" as its handled manually
|
|
22
|
+
const MAPLIBRE_OPTIONS = [
|
|
23
|
+
"antialias", "bearing", "bearingSnap", "bounds",
|
|
22
24
|
"boxZoom", "center", "clickTolerance", "collectResourceTiming",
|
|
23
25
|
"cooperativeGestures", "crossSourceCollisions", "doubleClickZoom", "dragPan",
|
|
24
26
|
"dragRotate", "fadeDuration", "failIfMajorPerformanceCaveat", "fitBoundsOptions",
|
|
@@ -49,6 +51,7 @@ const filterMapLibreOptions = opts => Object.fromEntries(Object.entries(opts).fi
|
|
|
49
51
|
* @param {object} [options] The map options (any of [MapLibre GL settings](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions/) or any supplementary option defined here)
|
|
50
52
|
* @param {object} [options.raster] The MapLibre raster source for aerial background. This must be a JSON object following [MapLibre raster source definition](https://maplibre.org/maplibre-style-spec/sources/#raster).
|
|
51
53
|
* @param {string} [options.background=streets] Choose default map background to display (streets or aerial, if raster aerial background available). Defaults to street.
|
|
54
|
+
* @param {string} [options.attributionControl.customAttribution] To override default map attribution.
|
|
52
55
|
* @fires Panoramax.components.ui.Map#background-changed
|
|
53
56
|
* @fires Panoramax.components.ui.Map#users-changed
|
|
54
57
|
* @fires Panoramax.components.ui.Map#sequence-hover
|
|
@@ -95,7 +98,7 @@ export default class Map extends maplibregl.Map {
|
|
|
95
98
|
this._options.background = this._options.background || "streets";
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
this._attribution = new maplibregl.AttributionControl({ compact: false });
|
|
101
|
+
this._attribution = new maplibregl.AttributionControl({ compact: false, ...options.attributionControl });
|
|
99
102
|
this.addControl(this._attribution);
|
|
100
103
|
|
|
101
104
|
this._initMapPosition();
|
|
@@ -50,7 +50,6 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
|
|
|
50
50
|
let map_zoom = urlMap?.zoom || browserMap?.zoom || componentMap.zoom;
|
|
51
51
|
let map_pitch = urlMap?.pitch || componentMap.pitch;
|
|
52
52
|
let map_bearing = urlMap?.bearing || componentMap.bearing;
|
|
53
|
-
console.log(componentMap);
|
|
54
53
|
|
|
55
54
|
// - Component only
|
|
56
55
|
let geocoder = componentAttrs.geocoder;
|
|
@@ -61,6 +60,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
|
|
|
61
60
|
let lang = componentAttrs.lang;
|
|
62
61
|
let endpoint = componentAttrs.endpoint;
|
|
63
62
|
let map_raster = componentMap.raster;
|
|
63
|
+
let map_attribution = componentMap.attributionControl;
|
|
64
64
|
|
|
65
65
|
// - URL only
|
|
66
66
|
let psv_xyz = urlParams.xyz;
|
|
@@ -102,7 +102,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
|
|
|
102
102
|
};
|
|
103
103
|
this._psvPostInit = { xyz: psv_xyz };
|
|
104
104
|
|
|
105
|
-
this._mapInit = { raster: map_raster };
|
|
105
|
+
this._mapInit = { raster: map_raster, attributionControl: map_attribution };
|
|
106
106
|
this._mapAny = {
|
|
107
107
|
theme: map_theme,
|
|
108
108
|
background: map_background,
|