From 2cefac0323c644a1a692dcd8344a63a2b0bbeffb Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Sun, 26 Mar 2017 19:37:51 -0300 Subject: [PATCH] better error management when loading file --- README.md | 2 +- js/gpxedit.js | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d8eb510..9237354 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ GpxEdit : - allows you to add extra symbols in Nextcloud(\*) admin settings (section : additional) - works with server-side encryption. - works with shared files. -- loads GPX, KML, unicsv CSV, geotagged JPG files (requires Gpsbabel to convert files and python-pil to import pictures) +- loads GPX, KML, unicsv CSV, geotagged JPG files (requires Gpsbabel to convert files and import pictures) - loads tracks, routes and waypoints - saves tracks, routes and waypoints - supports waypoint symbols diff --git a/js/gpxedit.js b/js/gpxedit.js index 1e6cc19..e557f66 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -1009,18 +1009,27 @@ OC.dialogs.alert('The file does not exist or it is not supported', 'Load error'); } - else{ + else { parseGpx(response.gpx); - var bounds = gpxedit.editableLayers.getBounds(); - gpxedit.map.fitBounds( - bounds, - { - animate: true, - paddingTopLeft: [parseInt($('#sidebar').css('width')), 0] - } - ); - hideLoadingAnimation(); + try { + var bounds = gpxedit.editableLayers.getBounds(); + gpxedit.map.fitBounds( + bounds, + { + animate: true, + paddingTopLeft: [parseInt($('#sidebar').css('width')), 0] + } + ); + } + catch (err) { + console.log('Impossible to fit to bounds \n'+err); + } } + hideLoadingAnimation(); + }).fail(function (){ + OC.dialogs.alert('Failed to communicate with the server', + 'Load error'); + hideLoadingAnimation(); }); }