[hamradio-commits] [dump1090] 240/373: Fixed resetMap() bug Fixed resetMap()-funtion to reset map-settings to default. Map saves last location and zoom values to localStorage.

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Thu Oct 23 14:58:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

mernisse-guest pushed a commit to branch backport
in repository dump1090.

commit 10e33892e8cd56001577871f4ff82795429bb16d
Author: terribl <terri at rannalla.net>
Date:   Fri May 31 10:04:11 2013 +0300

    Fixed resetMap() bug
    Fixed resetMap()-funtion to reset map-settings to default. Map saves last location and zoom values to localStorage.
    
    Also added new css-class '.pointer'.
    
    	modified:   public_html/gmap.html
    	modified:   public_html/script.js
    	modified:   public_html/style.css
---
 public_html/gmap.html |  8 +++++++-
 public_html/script.js | 26 ++++++++++++++++++++++++--
 public_html/style.css |  3 +++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/public_html/gmap.html b/public_html/gmap.html
index a5c2df5..5f56ae4 100644
--- a/public_html/gmap.html
+++ b/public_html/gmap.html
@@ -39,7 +39,13 @@
 				</div>
 				<div id="sudo_buttons">
 					<table width="100%"><tr>
-						<td width="150" style="text-align: center;">[ <span onclick="resetMap();">Reset Map</span> ]</td><td></td><td width="150" style="text-align: center;" id="setings_button">[ <span onclick="optionsModal();">Settings</span> ]</td>
+						<td width="150" style="text-align: center;" class="pointer">
+						    [ <span onclick="resetMap();">Reset Map</span> ]
+						</td>
+						<td> </td>
+						<td width="150" style="text-align: center;" id="setings_button" class="pointer">
+						    [ <span onclick="optionsModal();">Settings</span> ]
+						</td>
 					</tr></table>
 				</div>
 
diff --git a/public_html/script.js b/public_html/script.js
index aad0f79..ca3faa8 100644
--- a/public_html/script.js
+++ b/public_html/script.js
@@ -145,6 +145,16 @@ function initialize() {
 
 	GoogleMap.mapTypes.set("dark_map", styledMap);
 	
+	// Listeners for newly created Map
+    google.maps.event.addListener(GoogleMap, 'center_changed', function() {
+        localStorage['CenterLat'] = GoogleMap.getCenter().lat();
+        localStorage['CenterLon'] = GoogleMap.getCenter().lng();
+    });
+    
+    google.maps.event.addListener(GoogleMap, 'zoom_changed', function() {
+        localStorage['ZoomLvl']  = GoogleMap.getZoom();
+    }); 
+	
 	// Add home marker if requested
 	if (SiteShow && (typeof SiteLat !==  'undefined' || typeof SiteLon !==  'undefined')) {
 	    var siteMarker  = new google.maps.LatLng(SiteLat, SiteLon);
@@ -547,10 +557,22 @@ function selectPlaneByHex(hex) {
 }
 
 function resetMap() {
-	GoogleMap.setZoom(parseInt(localStorage['ZoomLvl']));
-	GoogleMap.setCenter(new google.maps.LatLng(parseFloat(localStorage['CenterLat']), parseFloat(localStorage['CenterLon'])));
+    // 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)));
 	Selected = null;
 	refreshSelected();
+	refreshTableInfo();
 }
 
 function drawCircle(marker, distance) {
diff --git a/public_html/style.css b/public_html/style.css
index 9053a97..9251b27 100644
--- a/public_html/style.css
+++ b/public_html/style.css
@@ -23,3 +23,6 @@ table#optionsTabs { width: 100%; font-size: small; font-family: monospace; backg
 #selectedinfo       { font-size: small; }
 #selectedinfo a     { text-decoration: none; color: blue; font-size: x-small;}
 #selectedinfo.dim   { opacity: 0.3; filter:alpha(opacity=30); /* For IE8 and earlier */ }
+
+.pointer { cursor: pointer; }
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git



More information about the pkg-hamradio-commits mailing list