diff --git a/htdocs/public/index.php b/htdocs/public/index.php index e47bb75..2333f6b 100755 --- a/htdocs/public/index.php +++ b/htdocs/public/index.php @@ -84,17 +84,19 @@ // Set this setting to false if you want to stop animations options['animate'] = true; + // Use Stockholm as default position (will be used if we fail to fetch location from ip-location service) + options['defaultLatitude'] = '59.30928'; + options['defaultLongitude'] = '18.08830'; + // Tip: request position from some ip->location service (here using freegeoip as an example) $.getJSON('https://freegeoip.app/json/', function(data) { if (data.latitude && data.longitude) { options['defaultLatitude'] = data.latitude; options['defaultLongitude'] = data.longitude; - } else { - // Default to Stockholm :-) - options['defaultLatitude'] = '59.30928'; - options['defaultLongitude'] = '18.08830'; } - + }).fail(function() { + console.log('Failed to fetch location, using default location'); + }).always(function() { var maptilerKey = ''; options['mapboxGLStyle'] = 'https://api.maptiler.com/maps/bright/style.json?optimize=true&key=' + maptilerKey;