@@ -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
2022var Dump1090Version = "unknown version" ;
2123var 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
161163function 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
687693function 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
710706function drawCircle ( marker , distance ) {
0 commit comments