Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
LukePrior committed Jul 12, 2021
commit 5d72cdb0f527fdc6c5d5acfa86fca6c5b569ef1f
7 changes: 3 additions & 4 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ 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, '_');
}

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) {
Expand Down Expand Up @@ -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);
Expand Down
60 changes: 26 additions & 34 deletions js/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<select name="timeperiod" id="timeperiod" style="width:auto !important;height:30px;" onchange="clean_refresh(this.value)"><option value="1 hour">1 hour</option><option value="3 hours" selected="selected">3 hours</option><option value="6 hours">6 hours</option><option value="12 hours">12 hours</option></select>';
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);

Expand Down Expand Up @@ -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 = '<select name="timeperiod" id="timeperiod" style="width:auto !important;height:30px;" onchange="clean_refresh(this.value)"><option value="1 hour">1 hour</option><option value="3 hours" selected="selected">3 hours</option><option value="6 hours">6 hours</option><option value="12 hours">12 hours</option></select>';
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() {
Expand Down Expand Up @@ -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;
Expand Down