From 10e33892e8cd56001577871f4ff82795429bb16d Mon Sep 17 00:00:00 2001 From: terribl Date: Fri, 31 May 2013 10:04:11 +0300 Subject: [PATCH] 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 @@
- + + +
[ Reset Map ][ Settings ] + [ Reset Map ] +   + [ Settings ] +
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; } +