update URL so it can be used to refer to a plane/location

This commit is contained in:
Matthias Wirth
2020-01-11 22:15:03 +01:00
parent f7c458b86e
commit a081136e40

View File

@@ -71,6 +71,7 @@ var PendingFetches = 0;
var lastReqestFiles = 0;
var debugCounter = 0;
var selectedPhotoCache = null;
var pathName = null;
var SpecialSquawks = {
'7500' : { cssClass: 'squawk7500', markerColor: 'rgb(255, 85, 85)', text: 'Aircraft Hijacking' },
@@ -879,6 +880,8 @@ function parse_history() {
} else {
sortByAltitude();
}
pathName = window.location.pathname;
window.setInterval(updateAddressBar, 1000);
}
// Make a LineString with 'points'-number points
@@ -1062,8 +1065,10 @@ function initialize_map() {
// Listeners for newly created Map
OLMap.getView().on('change:center', function(event) {
const center = ol.proj.toLonLat(OLMap.getView().getCenter(), OLMap.getView().getProjection());
CenterLat = center[1];
CenterLon = center[0];
if (FollowSelected) {
const center = ol.proj.toLonLat(OLMap.getView().getCenter(), OLMap.getView().getProjection());
// On manual navigation, disable follow
if (!SelectedPlane || !SelectedPlane.position ||
(Math.abs(center[0] - SelectedPlane.position[0]) > 0.0001 &&
@@ -1084,6 +1089,8 @@ function initialize_map() {
if (Math.abs(ZoomLvl-ZoomLvlCache) < 0.1)
return;
localStorage['ZoomLvl'] = ZoomLvl;
ZoomLvlCache = ZoomLvl;
clearTimeout(zoomTimeout);
@@ -3216,3 +3223,21 @@ function inView(tableplane, currExtent) {
}
return inView;
}
function updateAddressBar() {
var posString = 'lat=' + CenterLat.toFixed(3) + '&lon=' + CenterLon.toFixed(3) + '&zoom=' + ZoomLvl.toFixed(1);
var string;
if (true || !globeIndex)
posString = ""
else if (SelectedPlane)
posString = "&" + posString;
else
posString = "?" + posString;
if (SelectedPlane)
string = pathName + '?icao=' + SelectedPlane.icao + posString;
else
string = pathName + posString;
window.history.replaceState("object or string", "Title", string);
}