From 03ec14f555ae5b88f8862b9c736bca2f6dbbb3ca Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 11 Jul 2021 19:24:53 +1000 Subject: [PATCH 1/5] fix map issue --- js/tracker.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index 9f2eb0d..e96e81e 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -449,15 +449,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")) { @@ -516,10 +508,11 @@ function load() { 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(); }); From 5d72cdb0f527fdc6c5d5acfa86fca6c5b569ef1f Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Mon, 12 Jul 2021 11:03:50 +1000 Subject: [PATCH 2/5] fix --- js/app.js | 7 +++--- js/tracker.js | 60 ++++++++++++++++++++++----------------------------- 2 files changed, 29 insertions(+), 38 deletions(-) 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 e96e81e..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); @@ -483,43 +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('moveend', function() { lhash_update(); - }); + }); + map.on('baselayerchange', function(e) { selectedLayer = e.layer.id; lhash_update(); }); - + startAjax(); - }; - - map.whenReady(callBack); + }); // animate-in the timebox, setTimeout(function() { @@ -2621,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; From 4373e928057eb8f417e6dbe4b302215ecbe12ca2 Mon Sep 17 00:00:00 2001 From: Luke Prior <22492406+LukePrior@users.noreply.github.com> Date: Mon, 12 Jul 2021 19:26:59 +1000 Subject: [PATCH 3/5] Revert "Two fixes" --- js/app.js | 7 ++--- js/tracker.js | 75 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/js/app.js b/js/app.js index c5c17e4..3d7c284 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=" + roundNumber(map.getZoom(),0); + hash += "&mz=" + map.getZoom(); if(!/^[a-z0-9]{32}$/ig.exec(wvar.query)) { hash += "&qm=" + wvar.mode.replace(/ /g, '_'); @@ -22,7 +22,8 @@ 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) { @@ -107,7 +108,7 @@ function load_hash(no_refresh) { manual_pan = true; v = v.split(','); var latlng = new L.LatLng(v[0], v[1]); - map.panTo(latlng, {animate: false}); + map.setView(latlng); break; case "f": refocus = (follow_vehicle != v); diff --git a/js/tracker.js b/js/tracker.js index b228eea..9f2eb0d 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -428,27 +428,6 @@ 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); @@ -470,7 +449,15 @@ 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")) { @@ -504,20 +491,42 @@ function load() { if(!wvar.embeded) manual_pan = true; }); - map.once('move', function() { + // only start population the map, once its completely loaded + var callBack = function() { load_hash(null); - map.on('moveend', function() { - lhash_update(); - }); + L.Control.PeriodControl = L.Control.extend({ + onAdd: function(map) { + var div = L.DomUtil.create('div'); + + div.innerHTML = ''; + div.innerHTML.onload = setTimeValue(); - map.on('baselayerchange', function(e) { - selectedLayer = e.layer.id; - lhash_update(); + 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() { + lhash_update(); + }); + map.on('baselayerchange', function() { + lhash_update(); + }); + startAjax(); - }); + }; + + map.whenReady(callBack); // animate-in the timebox, setTimeout(function() { @@ -2619,6 +2628,12 @@ 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; From 062b3456a0e70615b1e6af0930436606e847131d Mon Sep 17 00:00:00 2001 From: Luke Prior <22492406+LukePrior@users.noreply.github.com> Date: Mon, 12 Jul 2021 19:28:58 +1000 Subject: [PATCH 4/5] Update tracker.js --- js/tracker.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index 9f2eb0d..fd91c96 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -2628,12 +2628,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; From dc33015d7864f126d4b264dd28e6558f8228441f Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Mon, 12 Jul 2021 20:15:05 +1000 Subject: [PATCH 5/5] Fix the issue using less bad code --- js/app.js | 2 +- js/tracker.js | 50 +++++++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/js/app.js b/js/app.js index 3d7c284..30bb1a6 100644 --- a/js/app.js +++ b/js/app.js @@ -108,7 +108,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); break; case "f": refocus = (follow_vehicle != v); diff --git a/js/tracker.js b/js/tracker.js index fd91c96..e6a1379 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -389,11 +389,14 @@ function load() { map = new L.map(document.getElementById('map'), { zoom: 5, zoomControl: false, - center: [53.467511,-2.2338940], + zoomAnimationThreshold: 0, + center: [53.467511,-2.233894], layers: [osm], preferCanvas: true, }); + map.setView([53.467511,-2.233894], 5, {animate: false}); + // fullscreen button map.addControl(new L.Control.Fullscreen({ position: 'bottomleft' })); @@ -428,6 +431,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); @@ -494,29 +518,9 @@ function load() { // only start population the map, once its completely loaded var callBack = function() { load_hash(null); + map.options.zoomAnimationThreshold = 4; - 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() {