diff --git a/js/app.js b/js/app.js index 3d7c284..c5c17e4 100644 --- a/js/app.js +++ b/js/app.js @@ -14,7 +14,7 @@ function lhash_update(history_step) { // generate hash hash += "mt=" + selectedLayer; - hash += "&mz=" + map.getZoom(); + hash += "&mz=" + roundNumber(map.getZoom(),0); if(!/^[a-z0-9]{32}$/ig.exec(wvar.query)) { hash += "&qm=" + wvar.mode.replace(/ /g, '_'); @@ -22,8 +22,7 @@ function lhash_update(history_step) { if(follow_vehicle === null || manual_pan) { var latlng = map.getCenter(); - hash += "&mc=" + roundNumber(latlng.lat, 5) + - "," + roundNumber(latlng.lng, 5); + hash += "&mc=" + roundNumber(latlng.lat, 5) + "," + roundNumber(latlng.lng, 5); } if(follow_vehicle !== null) { @@ -108,7 +107,7 @@ function load_hash(no_refresh) { manual_pan = true; v = v.split(','); var latlng = new L.LatLng(v[0], v[1]); - map.setView(latlng); + map.panTo(latlng, {animate: false}); break; case "f": refocus = (follow_vehicle != v); diff --git a/js/tracker.js b/js/tracker.js index 9f2eb0d..b228eea 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -428,6 +428,27 @@ function load() { L.control.status({ position: 'bottomright' }).addTo(map); + L.Control.PeriodControl = L.Control.extend({ + onAdd: function(map) { + var div = L.DomUtil.create('div'); + + div.innerHTML = ''; + div.innerHTML.onload = setTimeValue(); + + return div; + }, + + onRemove: function(map) { + // Nothing to do here + } + }); + + L.control.periodcontrol = function(opts) { + return new L.Control.PeriodControl(opts); + } + + L.control.periodcontrol({ position: 'topleft' }).addTo(map); + // update current position if we geolocation is available if(currentPosition) updateCurrentPosition(currentPosition.lat, currentPosition.lon); @@ -449,15 +470,7 @@ function load() { showLaunchSites(); map.addLayer(launches); } - - map.on('moveend', function (e) { - lhash_update(); - }); - - map.on('baselayerchange', function (e) { - selectedLayer = e.layer.id; - }); - + map.on('zoomend', function() { //do check for horizon labels if (!offline.get("opt_hide_horizon")) { @@ -491,42 +504,20 @@ function load() { if(!wvar.embeded) manual_pan = true; }); - // only start population the map, once its completely loaded - var callBack = function() { + map.once('move', function() { load_hash(null); - L.Control.PeriodControl = L.Control.extend({ - onAdd: function(map) { - var div = L.DomUtil.create('div'); - - div.innerHTML = ''; - div.innerHTML.onload = setTimeValue(); - - return div; - }, - - onRemove: function(map) { - // Nothing to do here - } - }); - - L.control.periodcontrol = function(opts) { - return new L.Control.PeriodControl(opts); - } - - L.control.periodcontrol({ position: 'topleft' }).addTo(map); - - map.on('idle', function() { + map.on('moveend', function() { lhash_update(); - }); - map.on('baselayerchange', function() { + }); + + map.on('baselayerchange', function(e) { + selectedLayer = e.layer.id; lhash_update(); }); - + startAjax(); - }; - - map.whenReady(callBack); + }); // animate-in the timebox, setTimeout(function() { @@ -2628,12 +2619,6 @@ function refresh() { periodical = setTimeout(refresh, 2000); return; } - - if (ajax_inprogress_old == wvar.query) { - if (vehicles.hasOwnProperty(wvar.query)) { - return; - } - } if (ajax_inprogress_old != wvar.query) { document.getElementById("timeperiod").disabled = false;