From a081136e409a7a54f59e2ebf54fe3b7c010cc97a Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sat, 11 Jan 2020 22:15:03 +0100 Subject: [PATCH] update URL so it can be used to refer to a plane/location --- html/script.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/html/script.js b/html/script.js index 2bf1f6c..bb5eddb 100644 --- a/html/script.js +++ b/html/script.js @@ -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); +}