Remember map type selection in local storage.

Fixes #26.
This commit is contained in:
Oliver Jowett 2015-10-26 23:03:34 +00:00
parent ecc45517d6
commit 91fce10f30

View file

@ -15,7 +15,7 @@ var SpecialSquawks = {
}; };
// Get current map settings // Get current map settings
var CenterLat, CenterLon, ZoomLvl; var CenterLat, CenterLon, ZoomLvl, MapType;
var Dump1090Version = "unknown version"; var Dump1090Version = "unknown version";
var RefreshInterval = 1000; var RefreshInterval = 1000;
@ -316,6 +316,7 @@ function initialize_map() {
CenterLat = Number(localStorage['CenterLat']) || DefaultCenterLat; CenterLat = Number(localStorage['CenterLat']) || DefaultCenterLat;
CenterLon = Number(localStorage['CenterLon']) || DefaultCenterLon; CenterLon = Number(localStorage['CenterLon']) || DefaultCenterLon;
ZoomLvl = Number(localStorage['ZoomLvl']) || DefaultZoomLvl; ZoomLvl = Number(localStorage['ZoomLvl']) || DefaultZoomLvl;
MapType = localStorage['MapType'] || google.maps.MapTypeId.ROADMAP;
// Set SitePosition, initialize sorting // Set SitePosition, initialize sorting
if (SiteShow && (typeof SiteLat !== 'undefined') && (typeof SiteLon !== 'undefined')) { if (SiteShow && (typeof SiteLat !== 'undefined') && (typeof SiteLon !== 'undefined')) {
@ -417,7 +418,7 @@ function initialize_map() {
var mapOptions = { var mapOptions = {
center: new google.maps.LatLng(CenterLat, CenterLon), center: new google.maps.LatLng(CenterLat, CenterLon),
zoom: ZoomLvl, zoom: ZoomLvl,
mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeId: MapType,
mapTypeControl: true, mapTypeControl: true,
streetViewControl: false, streetViewControl: false,
zoomControl: true, zoomControl: true,
@ -461,6 +462,10 @@ function initialize_map() {
localStorage['ZoomLvl'] = GoogleMap.getZoom(); localStorage['ZoomLvl'] = GoogleMap.getZoom();
}); });
google.maps.event.addListener(GoogleMap, 'maptypeid_changed', function() {
localStorage['MapType'] = GoogleMap.getMapTypeId();
});
// Add home marker if requested // Add home marker if requested
if (SitePosition) { if (SitePosition) {
var markerImage = new google.maps.MarkerImage( var markerImage = new google.maps.MarkerImage(
@ -836,6 +841,7 @@ function resetMap() {
localStorage['CenterLat'] = CenterLat = DefaultCenterLat; localStorage['CenterLat'] = CenterLat = DefaultCenterLat;
localStorage['CenterLon'] = CenterLon = DefaultCenterLon; localStorage['CenterLon'] = CenterLon = DefaultCenterLon;
localStorage['ZoomLvl'] = ZoomLvl = DefaultZoomLvl; localStorage['ZoomLvl'] = ZoomLvl = DefaultZoomLvl;
localStorage['MapType'] = MapType = google.maps.MapTypeId.ROADMAP;
// Set and refresh // Set and refresh
GoogleMap.setZoom(ZoomLvl); GoogleMap.setZoom(ZoomLvl);