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
This commit is contained in:
parent
072fba8718
commit
10e33892e8
|
@ -39,7 +39,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="sudo_buttons">
|
<div id="sudo_buttons">
|
||||||
<table width="100%"><tr>
|
<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>
|
</tr></table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,16 @@ function initialize() {
|
||||||
|
|
||||||
GoogleMap.mapTypes.set("dark_map", styledMap);
|
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
|
// Add home marker if requested
|
||||||
if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) {
|
if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) {
|
||||||
var siteMarker = new google.maps.LatLng(SiteLat, SiteLon);
|
var siteMarker = new google.maps.LatLng(SiteLat, SiteLon);
|
||||||
|
@ -547,10 +557,22 @@ function selectPlaneByHex(hex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetMap() {
|
function resetMap() {
|
||||||
GoogleMap.setZoom(parseInt(localStorage['ZoomLvl']));
|
// Reset localStorage values
|
||||||
GoogleMap.setCenter(new google.maps.LatLng(parseFloat(localStorage['CenterLat']), parseFloat(localStorage['CenterLon'])));
|
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;
|
Selected = null;
|
||||||
refreshSelected();
|
refreshSelected();
|
||||||
|
refreshTableInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawCircle(marker, distance) {
|
function drawCircle(marker, distance) {
|
||||||
|
|
|
@ -23,3 +23,6 @@ table#optionsTabs { width: 100%; font-size: small; font-family: monospace; backg
|
||||||
#selectedinfo { font-size: small; }
|
#selectedinfo { font-size: small; }
|
||||||
#selectedinfo a { text-decoration: none; color: blue; font-size: x-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 */ }
|
#selectedinfo.dim { opacity: 0.3; filter:alpha(opacity=30); /* For IE8 and earlier */ }
|
||||||
|
|
||||||
|
.pointer { cursor: pointer; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue