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:
terribl 2013-05-31 10:04:11 +03:00
parent 072fba8718
commit 10e33892e8
3 changed files with 34 additions and 3 deletions
public_html

View file

@ -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) {