mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
update bounds whenever files are added
This commit is contained in:
@@ -45,6 +45,16 @@ function updateGPXData() {
|
||||
}
|
||||
|
||||
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) => {
|
||||
if (!files.has(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);
|
||||
|
||||
selectFileWhenLoaded(files[0]._data.id);
|
||||
|
Reference in New Issue
Block a user