Skip to content
This repository has been archived by the owner on Sep 14, 2019. It is now read-only.

Commit

Permalink
Fix initial map centering thinkos.
Browse files Browse the repository at this point in the history
  • Loading branch information
mutability committed Jan 7, 2015
1 parent 94f62e5 commit 35e5088
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
6 changes: 4 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dump1090-mutability (1.10.3010.14mu-10) UNRELEASED; urgency=medium
dump1090-mutability (1.10.3010.14mu-10) unstable; urgency=medium

* Many changes to aircraft.json and the webserver code:

Expand Down Expand Up @@ -49,7 +49,9 @@ dump1090-mutability (1.10.3010.14mu-10) UNRELEASED; urgency=medium
* Remove extension.js and options.js, as they aren't really maintained.
* Enable strict mode for script.js / planeObject.js.

-- Oliver Jowett <[email protected]> Mon, 05 Jan 2015 21:43:58 +0000
* Fix initial map centering to correctly use the receiver location.

-- Oliver Jowett <[email protected]> Wed, 07 Jan 2015 23:54:10 +0000

dump1090-mutability (1.10.3010.14mu-9) unstable; urgency=medium

Expand Down
46 changes: 21 additions & 25 deletions public_html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ var SpecialSquawks = {
};

// Get current map settings
var CenterLat = Number(localStorage['CenterLat']) || CONST_CENTERLAT;
var CenterLon = Number(localStorage['CenterLon']) || CONST_CENTERLON;
var ZoomLvl = Number(localStorage['ZoomLvl']) || CONST_ZOOMLVL;
var DefaultCenterLat = CONST_CENTERLAT;
var DefaultCenterLon = CONST_CENTERLON;
var DefaultZoomLvl = CONST_ZOOMLVL;

var CenterLat, CenterLon, ZoomLvl;

var Dump1090Version = "unknown version";
var RefreshInterval = 1000;
Expand Down Expand Up @@ -147,8 +149,8 @@ function initialize() {
SiteShow = true;
SiteLat = data.lat;
SiteLon = data.lon;
CONST_CENTERLAT = data.lat;
CONST_CENTERLON = data.lon;
DefaultCenterLat = data.lat;
DefaultCenterLon = data.lon;
}

Dump1090Version = data.version;
Expand All @@ -159,8 +161,12 @@ function initialize() {

// Initalizes the map and starts up our timers to call various functions
function initialize_after_config() {
// Set SitePosition, initialize sorting
// Load stored map settings if present
CenterLat = Number(localStorage['CenterLat']) || DefaultCenterLat;
CenterLon = Number(localStorage['CenterLon']) || DefaultCenterLon;
ZoomLvl = Number(localStorage['ZoomLvl']) || DefaultZoomLvl;

// Set SitePosition, initialize sorting
if (SiteShow && (typeof SiteLat !== 'undefined') && (typeof SiteLon !== 'undefined')) {
SitePosition = new google.maps.LatLng(SiteLat, SiteLon);
sortByDistance();
Expand Down Expand Up @@ -685,26 +691,16 @@ function selectPlaneByHex(hex) {
}

function resetMap() {
// Reset localStorage values
localStorage['CenterLat'] = CONST_CENTERLAT;
localStorage['CenterLon'] = CONST_CENTERLON;
localStorage['ZoomLvl'] = CONST_ZOOMLVL;

// Try to read values from localStorage else use CONST_s
CenterLat = Number(localStorage['CenterLat']) || CONST_CENTERLAT;
CenterLon = Number(localStorage['CenterLon']) || CONST_CENTERLON;
ZoomLvl = Number(localStorage['ZoomLvl']) || CONST_ZOOMLVL;

// Set and refresh
GoogleMap.setZoom(parseInt(ZoomLvl));
GoogleMap.setCenter(new google.maps.LatLng(parseFloat(CenterLat), parseFloat(CenterLon)));
// Reset localStorage values and map settings
localStorage['CenterLat'] = CenterLat = DefaultCenterLat;
localStorage['CenterLon'] = CenterLon = DefaultCenterLon;
localStorage['ZoomLvl'] = ZoomLvl = DefaultZoomLvl;

// Set and refresh
GoogleMap.setZoom(ZoomLvl);
GoogleMap.setCenter(new google.maps.LatLng(CenterLat, CenterLon));

if (SelectedPlane) {
selectPlaneByHex(SelectedPlane);
}

refreshSelected();
refreshTableInfo();
selectPlaneByHex(null);
}

function drawCircle(marker, distance) {
Expand Down

0 comments on commit 35e5088

Please sign in to comment.