@panoramax/web-viewer 3.2.2-develop-43e56902 → 3.2.2-develop-19a0de46
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/CHANGELOG.md +4 -0
- package/build/editor.html +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/public/editor.html +3 -3
- package/src/Editor.js +34 -34
- package/src/utils/API.js +18 -2
package/package.json
CHANGED
package/public/editor.html
CHANGED
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
window.onload = () => {
|
|
34
34
|
editor = new Panoramax.Editor(
|
|
35
35
|
"editor",
|
|
36
|
-
"https://
|
|
36
|
+
"https://panoramax.openstreetmap.fr/api",
|
|
37
37
|
{
|
|
38
|
-
selectedSequence: "
|
|
39
|
-
selectedPicture:
|
|
38
|
+
selectedSequence: "ecfe4b2c-0acd-4d3a-a10d-c3e6818755c8",
|
|
39
|
+
selectedPicture: "329af5c6-4761-4a6d-9c1e-674fd6daa8b6",
|
|
40
40
|
background: "aerial",
|
|
41
41
|
raster: {
|
|
42
42
|
type: "raster",
|
package/src/Editor.js
CHANGED
|
@@ -59,14 +59,11 @@ export default class Editor extends CoreView {
|
|
|
59
59
|
raster: options.raster,
|
|
60
60
|
background: options.background,
|
|
61
61
|
supplementaryStyle: this._createMapStyle(),
|
|
62
|
+
zoom: 15, // Hack to avoid _initMapPosition call
|
|
62
63
|
});
|
|
63
64
|
linkMapAndPhoto(this);
|
|
64
65
|
this._loadSequence();
|
|
65
66
|
this.map.once("load", () => {
|
|
66
|
-
this.map.setPaintProperty("geovisio_editor_sequences", "line-color", this.map._getLayerColorStyle("sequences"));
|
|
67
|
-
this.map.setPaintProperty("geovisio_editor_pictures", "circle-color", this.map._getLayerColorStyle("pictures"));
|
|
68
|
-
this.map.setLayoutProperty("geovisio_editor_sequences", "visibility", "visible");
|
|
69
|
-
this.map.setLayoutProperty("geovisio_editor_pictures", "visibility", "visible");
|
|
70
67
|
if(options.raster) { this._addMapBackgroundWidget(); }
|
|
71
68
|
this._bindPicturesEvents();
|
|
72
69
|
});
|
|
@@ -153,6 +150,15 @@ export default class Editor extends CoreView {
|
|
|
153
150
|
*/
|
|
154
151
|
_loadSequence() {
|
|
155
152
|
return this._api.getSequenceItems(this._selectedSeqId).then(seq => {
|
|
153
|
+
// Hide loader after source load
|
|
154
|
+
this.map.once("sourcedata", () => {
|
|
155
|
+
this.map.setPaintProperty("geovisio_editor_sequences", "line-color", this.map._getLayerColorStyle("sequences"));
|
|
156
|
+
this.map.setPaintProperty("geovisio_editor_pictures", "circle-color", this.map._getLayerColorStyle("pictures"));
|
|
157
|
+
this.map.setLayoutProperty("geovisio_editor_sequences", "visibility", "visible");
|
|
158
|
+
this.map.setLayoutProperty("geovisio_editor_pictures", "visibility", "visible");
|
|
159
|
+
this.map.once("styledata", () => this._loader.dismiss());
|
|
160
|
+
});
|
|
161
|
+
|
|
156
162
|
// Create data source
|
|
157
163
|
this._sequenceData = seq.features;
|
|
158
164
|
this.map.getSource("geovisio_editor_sequences").setData({
|
|
@@ -177,40 +183,34 @@ export default class Editor extends CoreView {
|
|
|
177
183
|
]
|
|
178
184
|
});
|
|
179
185
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
this.map.jumpTo({ center: pic.geometry.coordinates, zoom: 18 });
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
console.log("Picture with ID", pic, "was not found");
|
|
190
|
-
}
|
|
186
|
+
// Select picture if any
|
|
187
|
+
if(this._selectedPicId) {
|
|
188
|
+
const pic = seq.features.find(p => p.id === this._selectedPicId);
|
|
189
|
+
if(pic) {
|
|
190
|
+
this.select(this._selectedSeqId, this._selectedPicId, true);
|
|
191
|
+
this.map.jumpTo({ center: pic.geometry.coordinates, zoom: 18 });
|
|
191
192
|
}
|
|
192
|
-
// Show area of sequence otherwise
|
|
193
193
|
else {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
console.log("Picture with ID", pic, "was not found");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Show area of sequence otherwise
|
|
198
|
+
else {
|
|
199
|
+
const bbox = [
|
|
200
|
+
...seq.features[0].geometry.coordinates,
|
|
201
|
+
...seq.features[0].geometry.coordinates
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
for(let i=1; i < seq.features.length; i++) {
|
|
205
|
+
const c = seq.features[i].geometry.coordinates;
|
|
206
|
+
if(c[0] < bbox[0]) { bbox[0] = c[0]; }
|
|
207
|
+
if(c[1] < bbox[1]) { bbox[1] = c[1]; }
|
|
208
|
+
if(c[0] > bbox[2]) { bbox[2] = c[0]; }
|
|
209
|
+
if(c[1] > bbox[3]) { bbox[3] = c[1]; }
|
|
208
210
|
}
|
|
209
|
-
this._loader.dismiss();
|
|
210
|
-
};
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
this.map.fitBounds(bbox, {animate: false});
|
|
213
|
+
}
|
|
214
214
|
}).catch(e => this._loader.dismiss(e, this._t.gvs.error_api));
|
|
215
215
|
}
|
|
216
216
|
|
package/src/utils/API.js
CHANGED
|
@@ -336,13 +336,29 @@ export default class API {
|
|
|
336
336
|
* Get sequence GeoJSON representation
|
|
337
337
|
*
|
|
338
338
|
* @param {string} seqId The sequence ID
|
|
339
|
+
* @param {string} [next] The next link URL (only for internals)
|
|
340
|
+
* @param {object} [data] The previous dataset (only for internals)
|
|
339
341
|
* @returns {Promise} Resolves on sequence GeoJSON
|
|
340
342
|
*/
|
|
341
|
-
async getSequenceItems(seqId) {
|
|
343
|
+
async getSequenceItems(seqId, next = null, data = null) {
|
|
342
344
|
if(!this.isReady()) { throw new Error("API is not ready to use"); }
|
|
343
345
|
try {
|
|
344
346
|
API.isIdValid(seqId);
|
|
345
|
-
return fetch(
|
|
347
|
+
return fetch(
|
|
348
|
+
next || `${this._endpoints.collections}/${seqId}/items`,
|
|
349
|
+
this._getFetchOptions()
|
|
350
|
+
)
|
|
351
|
+
.then(res => res.json())
|
|
352
|
+
.then(res => {
|
|
353
|
+
// Merge previous data with current page
|
|
354
|
+
let nextData = res;
|
|
355
|
+
if(data) { nextData.features = data.features.concat(nextData.features); }
|
|
356
|
+
|
|
357
|
+
// Handle pagination for next link
|
|
358
|
+
const nextLink = res.links.find(l => l.rel === "next");
|
|
359
|
+
if(nextLink) { return this.getSequenceItems(seqId, nextLink.href, nextData); }
|
|
360
|
+
else { return nextData; }
|
|
361
|
+
});
|
|
346
362
|
}
|
|
347
363
|
catch(e) {
|
|
348
364
|
return Promise.reject(e);
|