update bounds whenever files are added
This commit is contained in:
parent
44cc39fbd6
commit
f2bba14174
1 changed files with 10 additions and 8 deletions
|
@ -45,6 +45,16 @@ function updateGPXData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fileObservers.subscribe((files) => { // Maintain up-to-date statistics
|
fileObservers.subscribe((files) => { // Maintain up-to-date statistics
|
||||||
|
if (files.size > fileStatistics.size) { // Files are added
|
||||||
|
let bounds = new mapboxgl.LngLatBounds([180, 90, -180, -90]);
|
||||||
|
let mapBounds = new mapboxgl.LngLatBounds([180, 90, -180, -90]);
|
||||||
|
if (fileStatistics.size > 0) { // Some files are already loaded
|
||||||
|
mapBounds = get(map)?.getBounds() ?? mapBounds;
|
||||||
|
bounds.extend(mapBounds);
|
||||||
|
}
|
||||||
|
targetMapBounds.set(bounds);
|
||||||
|
}
|
||||||
|
|
||||||
fileStatistics.forEach((stats, fileId) => {
|
fileStatistics.forEach((stats, fileId) => {
|
||||||
if (!files.has(fileId)) {
|
if (!files.has(fileId)) {
|
||||||
fileStatistics.delete(fileId);
|
fileStatistics.delete(fileId);
|
||||||
|
@ -150,14 +160,6 @@ export async function loadFiles(list: FileList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let bounds = new mapboxgl.LngLatBounds([180, 90, -180, -90]);
|
|
||||||
let mapBounds = new mapboxgl.LngLatBounds([180, 90, -180, -90]);
|
|
||||||
if (get(fileObservers).size > 0) {
|
|
||||||
mapBounds = get(map)?.getBounds() ?? mapBounds;
|
|
||||||
bounds.extend(mapBounds);
|
|
||||||
}
|
|
||||||
targetMapBounds.set(bounds);
|
|
||||||
|
|
||||||
dbUtils.addMultiple(files);
|
dbUtils.addMultiple(files);
|
||||||
|
|
||||||
selectFileWhenLoaded(files[0]._data.id);
|
selectFileWhenLoaded(files[0]._data.id);
|
||||||
|
|
Loading…
Reference in a new issue