From 4bff4880aa21c314d315d45a306d48713363f98f Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Mon, 30 Oct 2017 11:07:41 +0100 Subject: [PATCH] Added direct zoom in live dashboard --- static/js/index/index.js | 20 -------------------- static/js/index/index_map.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/static/js/index/index.js b/static/js/index/index.js index ba5c257..21f161c 100644 --- a/static/js/index/index.js +++ b/static/js/index/index.js @@ -198,26 +198,6 @@ $(document).ready(function () { }); - $( "#rotation_wait_time_selector" ).change(function() { - var sel = parseInt($( this ).val()); - if(isNaN(sel)) { - rotation_wait_time = 0; - } else { - rotation_wait_time = sel; - } - var old = ROTATIONWAITTIME; - ROTATIONWAITTIME = 1000*rotation_wait_time; //seconds - if(old == 0) { - mapEventManager._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME); - } - }); - - $( "#zoom_selector" ).change(function() { - var sel = parseInt($( this ).val()); - zoomlevel = sel; - ZOOMLEVEL = sel; - }); - }); diff --git a/static/js/index/index_map.js b/static/js/index/index_map.js index eabf877..ae83f0e 100644 --- a/static/js/index/index_map.js +++ b/static/js/index/index_map.js @@ -30,6 +30,7 @@ class MapEvent { class MapEventManager { constructor() { this._mapEventArray = []; + this._currentMapEvent; this._nextEventToShow = 0; this._first_map = true; this._coordSet = new Set(); @@ -75,9 +76,14 @@ class MapEventManager { getNextEventToShow() { var toShow = this._mapEventArray[this._nextEventToShow]; this._nextEventToShow = this._nextEventToShow == this._mapEventArray.length-1 ? 0 : this._nextEventToShow+1; + this._currentMapEvent = toShow; return toShow; } + getCurrentMapEvent() { + return this._currentMapEvent; + } + // Perform the roration of the map in the openStreetMap pannel rotateMap(mapEvent) { clearTimeout(this._timeoutRotate); //cancel current map rotation @@ -96,6 +102,12 @@ class MapEventManager { } } + directZoom() { + var mapEvent = this.getCurrentMapEvent(); + if (mapEvent != undefined) + myOpenStreetMap.flyTo([mapEvent.coord.lat, mapEvent.coord.lon], ZOOMLEVEL); + } + ping() { var pnts = openStreetMapObj.latLngToPoint(this._latToPing, this._lonToPing); if (pnts != false) { //sometimes latLngToPoint return false @@ -206,3 +218,26 @@ function connect_source_map() { }; } connect_source_map() + +$(document).ready(function () { + $( "#rotation_wait_time_selector" ).change(function() { + var sel = parseInt($( this ).val()); + if(isNaN(sel)) { + rotation_wait_time = 0; + } else { + rotation_wait_time = sel; + } + var old = ROTATIONWAITTIME; + ROTATIONWAITTIME = 1000*rotation_wait_time; //seconds + if(old == 0) { + mapEventManager._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME); + } + }); + + $( "#zoom_selector" ).change(function() { + var sel = parseInt($( this ).val()); + ZOOMLEVEL = sel; + mapEventManager.directZoom(); + }); +}); +