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

Commit 35e5088

Browse files
committed
Fix initial map centering thinkos.
1 parent 94f62e5 commit 35e5088

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

debian/changelog

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dump1090-mutability (1.10.3010.14mu-10) UNRELEASED; urgency=medium
1+
dump1090-mutability (1.10.3010.14mu-10) unstable; urgency=medium
22

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

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

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

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

public_html/script.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ var SpecialSquawks = {
1313
};
1414

1515
// Get current map settings
16-
var CenterLat = Number(localStorage['CenterLat']) || CONST_CENTERLAT;
17-
var CenterLon = Number(localStorage['CenterLon']) || CONST_CENTERLON;
18-
var ZoomLvl = Number(localStorage['ZoomLvl']) || CONST_ZOOMLVL;
16+
var DefaultCenterLat = CONST_CENTERLAT;
17+
var DefaultCenterLon = CONST_CENTERLON;
18+
var DefaultZoomLvl = CONST_ZOOMLVL;
19+
20+
var CenterLat, CenterLon, ZoomLvl;
1921

2022
var Dump1090Version = "unknown version";
2123
var RefreshInterval = 1000;
@@ -147,8 +149,8 @@ function initialize() {
147149
SiteShow = true;
148150
SiteLat = data.lat;
149151
SiteLon = data.lon;
150-
CONST_CENTERLAT = data.lat;
151-
CONST_CENTERLON = data.lon;
152+
DefaultCenterLat = data.lat;
153+
DefaultCenterLon = data.lon;
152154
}
153155

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

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

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

687693
function resetMap() {
688-
// Reset localStorage values
689-
localStorage['CenterLat'] = CONST_CENTERLAT;
690-
localStorage['CenterLon'] = CONST_CENTERLON;
691-
localStorage['ZoomLvl'] = CONST_ZOOMLVL;
692-
693-
// Try to read values from localStorage else use CONST_s
694-
CenterLat = Number(localStorage['CenterLat']) || CONST_CENTERLAT;
695-
CenterLon = Number(localStorage['CenterLon']) || CONST_CENTERLON;
696-
ZoomLvl = Number(localStorage['ZoomLvl']) || CONST_ZOOMLVL;
697-
698-
// Set and refresh
699-
GoogleMap.setZoom(parseInt(ZoomLvl));
700-
GoogleMap.setCenter(new google.maps.LatLng(parseFloat(CenterLat), parseFloat(CenterLon)));
694+
// Reset localStorage values and map settings
695+
localStorage['CenterLat'] = CenterLat = DefaultCenterLat;
696+
localStorage['CenterLon'] = CenterLon = DefaultCenterLon;
697+
localStorage['ZoomLvl'] = ZoomLvl = DefaultZoomLvl;
698+
699+
// Set and refresh
700+
GoogleMap.setZoom(ZoomLvl);
701+
GoogleMap.setCenter(new google.maps.LatLng(CenterLat, CenterLon));
701702

702-
if (SelectedPlane) {
703-
selectPlaneByHex(SelectedPlane);
704-
}
705-
706-
refreshSelected();
707-
refreshTableInfo();
703+
selectPlaneByHex(null);
708704
}
709705

710706
function drawCircle(marker, distance) {

0 commit comments

Comments
 (0)