@panoramax/web-viewer 3.2.3-develop-d3aad6f3 → 3.2.3-develop-6a0bb22d
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 +2 -2
- package/build/index.js.map +1 -1
- package/docs/reference/components/core/Basic.md +1 -1
- package/docs/reference/components/core/CoverageMap.md +1 -1
- package/docs/reference/components/core/Editor.md +7 -0
- package/docs/reference/components/core/Viewer.md +7 -0
- package/docs/tutorials/map_style.md +3 -3
- package/docs/tutorials/migrate_v4.md +4 -0
- package/package.json +1 -1
- package/src/components/core/Basic.js +17 -9
- package/src/components/core/Editor.js +7 -0
- package/src/components/core/Viewer.js +9 -2
- package/src/components/menus/Share.js +1 -0
|
@@ -46,7 +46,7 @@ Component properties.
|
|
|
46
46
|
| [sequence] | <code>string</code> | | The sequence ID of the picture displayed |
|
|
47
47
|
| [fetchOptions] | <code>object</code> | | Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters)) |
|
|
48
48
|
| [users] | <code>Array.<string></code> | <code>[geovisio]</code> | List of users IDs to use for map display (defaults to general map, identified as "geovisio") |
|
|
49
|
-
| [
|
|
49
|
+
| [mapstyle] | <code>string</code> \| <code>object</code> | | The map's MapLibre style. This can be an a JSON object conforming to the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/), or a URL string pointing to one. Defaults to OSM vector tiles. |
|
|
50
50
|
| [lang] | <code>string</code> | | To override language used for labels. Defaults to using user's preferred languages. |
|
|
51
51
|
| endpoint | <code>string</code> | | URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md)) |
|
|
52
52
|
|
|
@@ -53,7 +53,7 @@ Component properties.
|
|
|
53
53
|
| [sequence] | <code>string</code> | | The sequence ID of the picture displayed |
|
|
54
54
|
| [fetchOptions] | <code>object</code> | | Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters)) |
|
|
55
55
|
| [users] | <code>Array.<string></code> | <code>[geovisio]</code> | List of users IDs to use for map display (defaults to general map, identified as "geovisio") |
|
|
56
|
-
| [
|
|
56
|
+
| [mapstyle] | <code>string</code> \| <code>object</code> | | The map's MapLibre style. This can be an a JSON object conforming to the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/), or a URL string pointing to one. Defaults to OSM vector tiles. |
|
|
57
57
|
| [lang] | <code>string</code> | | To override language used for labels. Defaults to using user's preferred languages. |
|
|
58
58
|
| endpoint | <code>string</code> | | URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md)) |
|
|
59
59
|
|
|
@@ -54,6 +54,13 @@ Component properties. All of [Basic properties](Basic.md/#Panoramax.components.c
|
|
|
54
54
|
|
|
55
55
|
| Name | Type | Default | Description |
|
|
56
56
|
| --- | --- | --- | --- |
|
|
57
|
+
| [picture] | <code>string</code> | | The picture ID to display |
|
|
58
|
+
| [sequence] | <code>string</code> | | The sequence ID of the picture displayed |
|
|
59
|
+
| [fetchOptions] | <code>object</code> | | Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters)) |
|
|
60
|
+
| [users] | <code>Array.<string></code> | <code>[geovisio]</code> | List of users IDs to use for map display (defaults to general map, identified as "geovisio") |
|
|
61
|
+
| [mapstyle] | <code>string</code> \| <code>object</code> | | The map's MapLibre style. This can be an a JSON object conforming to the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/), or a URL string pointing to one. Defaults to OSM vector tiles. |
|
|
62
|
+
| [lang] | <code>string</code> | | To override language used for labels. Defaults to using user's preferred languages. |
|
|
63
|
+
| endpoint | <code>string</code> | | URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md)) |
|
|
57
64
|
| [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). |
|
|
58
65
|
| [background] | <code>string</code> | <code>"streets"</code> | Choose default map background to display (streets or aerial, if raster aerial background available). Defaults to street. |
|
|
59
66
|
|
|
@@ -98,6 +98,13 @@ Component properties. All of [Basic properties](Basic.md/#Panoramax.components.c
|
|
|
98
98
|
| [focus] | <code>string</code> | <code>"pic"</code> | The component showing up as main component (pic, map) |
|
|
99
99
|
| [geocoder] | <code>string</code> | <code>"nominatim"</code> | The geocoder engine to use (nominatim, ban) |
|
|
100
100
|
| [widgets] | <code>string</code> | <code>true</code> | Use default set of widgets ? Set to false to avoid any widget to show up, and use slots to populate as you like. |
|
|
101
|
+
| [picture] | <code>string</code> | | The picture ID to display |
|
|
102
|
+
| [sequence] | <code>string</code> | | The sequence ID of the picture displayed |
|
|
103
|
+
| [fetchOptions] | <code>object</code> | | Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters)) |
|
|
104
|
+
| [users] | <code>Array.<string></code> | <code>[geovisio]</code> | List of users IDs to use for map display (defaults to general map, identified as "geovisio") |
|
|
105
|
+
| [mapstyle] | <code>string</code> \| <code>object</code> | | The map's MapLibre style. This can be an a JSON object conforming to the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/), or a URL string pointing to one. Defaults to OSM vector tiles. |
|
|
106
|
+
| [lang] | <code>string</code> | | To override language used for labels. Defaults to using user's preferred languages. |
|
|
107
|
+
| endpoint | <code>string</code> | | URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md)) |
|
|
101
108
|
|
|
102
109
|
<a name="Panoramax.components.core.Viewer+onceReady"></a>
|
|
103
110
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Change map background style
|
|
2
2
|
|
|
3
|
-
All components can be configured to use a different map background than the default one. By default, an OpenStreetMap France classic style if offered. Changing the style is done by passing a `
|
|
3
|
+
All components can be configured to use a different map background than the default one. By default, an OpenStreetMap France classic style if offered. Changing the style is done by passing a `mapstyle` parameter on viewer setup. It should follow the [MapLibre Style specification](https://maplibre.org/maplibre-style-spec) and be passed as an object, or an URL to such style:
|
|
4
4
|
|
|
5
5
|
```html
|
|
6
6
|
<pnx-viewer
|
|
7
7
|
endpoint="https://api.panoramax.xyz/api"
|
|
8
|
-
|
|
8
|
+
mapstyle="https://my.tiles.provider/basic.json"
|
|
9
9
|
/>
|
|
10
10
|
```
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ Note that we also support PMTiles (for a simpler tile hosting), so your style fi
|
|
|
14
14
|
```html
|
|
15
15
|
<pnx-viewer
|
|
16
16
|
endpoint="https://api.panoramax.xyz/api"
|
|
17
|
-
|
|
17
|
+
mapstyle='{
|
|
18
18
|
"sources": {
|
|
19
19
|
"protomaps": {
|
|
20
20
|
"type": "vector",
|
|
@@ -24,6 +24,8 @@ The way you create a component (viewer, editor, coverage map) is different :
|
|
|
24
24
|
let myviewer = document.getElementById("myviewer");
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Also note that custom MapLibre style must be passed as `mapstyle` attribute.
|
|
28
|
+
|
|
27
29
|
=== "v3"
|
|
28
30
|
|
|
29
31
|
Before, you created a `div` with ID, then passed it to JS class.
|
|
@@ -32,6 +34,8 @@ The way you create a component (viewer, editor, coverage map) is different :
|
|
|
32
34
|
let myViewer = new Panoramax.Viewer("viewer", "https://api.panoramax.xyz/api");
|
|
33
35
|
```
|
|
34
36
|
|
|
37
|
+
And MapLibre style was passed as a `style` property in option object.
|
|
38
|
+
|
|
35
39
|
## ⏯️ Widgets options
|
|
36
40
|
|
|
37
41
|
Viewer widgets options are managed quite differently in version 4:
|
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@ export default class Basic extends LitElement {
|
|
|
37
37
|
* @property {string} [sequence] The sequence ID of the picture displayed
|
|
38
38
|
* @property {object} [fetchOptions] Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters))
|
|
39
39
|
* @property {string[]} [users=[geovisio]] List of users IDs to use for map display (defaults to general map, identified as "geovisio")
|
|
40
|
-
* @property {string|object} [
|
|
40
|
+
* @property {string|object} [mapstyle] The map's MapLibre style. This can be an a JSON object conforming to the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/), or a URL string pointing to one. Defaults to OSM vector tiles.
|
|
41
41
|
* @property {string} [lang] To override language used for labels. Defaults to using user's preferred languages.
|
|
42
42
|
* @property {string} endpoint URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md))
|
|
43
43
|
*/
|
|
@@ -46,7 +46,7 @@ export default class Basic extends LitElement {
|
|
|
46
46
|
sequence: {type: String, reflect: true},
|
|
47
47
|
fetchOptions: {type: Object, attribute: false},
|
|
48
48
|
users: {type: Array, reflect: true},
|
|
49
|
-
|
|
49
|
+
mapstyle: {type: String},
|
|
50
50
|
lang: {type: String},
|
|
51
51
|
endpoint: {type: String},
|
|
52
52
|
};
|
|
@@ -56,7 +56,7 @@ export default class Basic extends LitElement {
|
|
|
56
56
|
|
|
57
57
|
// Some defaults
|
|
58
58
|
this.users = ["geovisio"];
|
|
59
|
-
this.
|
|
59
|
+
this.mapstyle = this.getAttribute("mapstyle") || DEFAULT_TILES;
|
|
60
60
|
this.lang = this.getAttribute("lang") || null;
|
|
61
61
|
this.endpoint = this.getAttribute("endpoint") || null; // No default
|
|
62
62
|
this.picture = null;
|
|
@@ -78,15 +78,18 @@ export default class Basic extends LitElement {
|
|
|
78
78
|
// Internet speed check
|
|
79
79
|
this._isInternetFast = null;
|
|
80
80
|
isInternetFast().then(isFast => this._isInternetFast = isFast);
|
|
81
|
+
}
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
connectedCallback() {
|
|
84
|
+
super.connectedCallback();
|
|
85
|
+
if(this.endpoint) { this._setupAPI(); }
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
89
|
* Creates API and wait for initial loading
|
|
87
90
|
* @private
|
|
88
91
|
*/
|
|
89
|
-
_setupAPI(
|
|
92
|
+
_setupAPI() {
|
|
90
93
|
// Loader init
|
|
91
94
|
this.loader = this.loader || createWebComp("pnx-loader", {_parent: this});
|
|
92
95
|
|
|
@@ -95,12 +98,17 @@ export default class Basic extends LitElement {
|
|
|
95
98
|
return;
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
//
|
|
101
|
+
// Check if mapstyle is not a unparsed JSON
|
|
102
|
+
try {
|
|
103
|
+
this.mapstyle = JSON.parse(this.mapstyle);
|
|
104
|
+
} catch(e) { /* empty */ }
|
|
105
|
+
|
|
106
|
+
// API init
|
|
99
107
|
try {
|
|
100
|
-
this.api = new API(endpoint, {
|
|
108
|
+
this.api = new API(this.endpoint, {
|
|
101
109
|
users: this.users,
|
|
102
110
|
fetch: this.fetchOptions,
|
|
103
|
-
style: this.
|
|
111
|
+
style: this.mapstyle,
|
|
104
112
|
});
|
|
105
113
|
this.api.onceReady()
|
|
106
114
|
.then(() => {
|
|
@@ -165,7 +173,7 @@ export default class Basic extends LitElement {
|
|
|
165
173
|
super.attributeChangedCallback(name, _old, value);
|
|
166
174
|
|
|
167
175
|
if(name === "endpoint") {
|
|
168
|
-
if(!this.api || this.api._endpoint !== value) { this._setupAPI(
|
|
176
|
+
if(!this.api || this.api._endpoint !== value) { this._setupAPI(); }
|
|
169
177
|
}
|
|
170
178
|
if(["picture", "sequence"].includes(name)) {
|
|
171
179
|
let seqId, picId, prevSeqId, prevPicId;
|
|
@@ -40,6 +40,13 @@ export default class Editor extends Basic {
|
|
|
40
40
|
* @memberof Panoramax.components.core.Editor#
|
|
41
41
|
* @mixes Panoramax.components.core.Basic#properties
|
|
42
42
|
* @type {Object}
|
|
43
|
+
* @property {string} [picture] The picture ID to display
|
|
44
|
+
* @property {string} [sequence] The sequence ID of the picture displayed
|
|
45
|
+
* @property {object} [fetchOptions] Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters))
|
|
46
|
+
* @property {string[]} [users=[geovisio]] List of users IDs to use for map display (defaults to general map, identified as "geovisio")
|
|
47
|
+
* @property {string|object} [mapstyle] The map's MapLibre style. This can be an a JSON object conforming to the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/), or a URL string pointing to one. Defaults to OSM vector tiles.
|
|
48
|
+
* @property {string} [lang] To override language used for labels. Defaults to using user's preferred languages.
|
|
49
|
+
* @property {string} endpoint URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md))
|
|
43
50
|
* @property {object} [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).
|
|
44
51
|
* @property {string} [background=streets] Choose default map background to display (streets or aerial, if raster aerial background available). Defaults to street.
|
|
45
52
|
*/
|
|
@@ -83,6 +83,13 @@ export default class Viewer extends Basic {
|
|
|
83
83
|
* @property {string} [focus=pic] The component showing up as main component (pic, map)
|
|
84
84
|
* @property {string} [geocoder=nominatim] The geocoder engine to use (nominatim, ban)
|
|
85
85
|
* @property {string} [widgets=true] Use default set of widgets ? Set to false to avoid any widget to show up, and use slots to populate as you like.
|
|
86
|
+
* @property {string} [picture] The picture ID to display
|
|
87
|
+
* @property {string} [sequence] The sequence ID of the picture displayed
|
|
88
|
+
* @property {object} [fetchOptions] Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters))
|
|
89
|
+
* @property {string[]} [users=[geovisio]] List of users IDs to use for map display (defaults to general map, identified as "geovisio")
|
|
90
|
+
* @property {string|object} [mapstyle] The map's MapLibre style. This can be an a JSON object conforming to the schema described in the [MapLibre Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/), or a URL string pointing to one. Defaults to OSM vector tiles.
|
|
91
|
+
* @property {string} [lang] To override language used for labels. Defaults to using user's preferred languages.
|
|
92
|
+
* @property {string} endpoint URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md))
|
|
86
93
|
*/
|
|
87
94
|
static properties = {
|
|
88
95
|
map: {type: Object},
|
|
@@ -157,8 +164,8 @@ export default class Viewer extends Basic {
|
|
|
157
164
|
// Init various widgets
|
|
158
165
|
if(myInitParams.widgets !== "false") {
|
|
159
166
|
this.grid.appendChild(createWebComp("pnx-widget-zoom", {
|
|
160
|
-
slot: this.
|
|
161
|
-
class: this.
|
|
167
|
+
slot: this.isWidthSmall() ? "top-left" : "bottom-right",
|
|
168
|
+
class: this.isWidthSmall() ? "pnx-only-map pnx-print-hidden" : "pnx-print-hidden",
|
|
162
169
|
_parent: this
|
|
163
170
|
}));
|
|
164
171
|
this.grid.appendChild(createWebComp("pnx-widget-share", {slot: "bottom-right", class: "pnx-print-hidden", _parent: this}));
|