Add "auto" map theme as default (changes between light and dark based on app theme)
This commit is contained in:
parent
0415aa565b
commit
7eb588dd44
@ -17,12 +17,21 @@ function leafletMap() {
|
|||||||
map.maptype = "leaflet";
|
map.maptype = "leaflet";
|
||||||
|
|
||||||
if (getStorage("mapsource") == null) {
|
if (getStorage("mapsource") == null) {
|
||||||
setStorage("mapsource", "liberty");
|
setStorage("mapsource", "auto");
|
||||||
|
}
|
||||||
|
mapsource = getStorage("mapsource");
|
||||||
|
|
||||||
|
if (mapsource == "auto") {
|
||||||
|
if ($("#app").hasClass("theme-dark")) {
|
||||||
|
mapsource = "libertydark";
|
||||||
|
} else {
|
||||||
|
mapsource = "liberty";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#mapbox").css("background-color", SETTINGS.maptileurls[getStorage("mapsource")].bgcolor);
|
$("#mapbox").css("background-color", SETTINGS.maptileurls[mapsource].bgcolor);
|
||||||
|
|
||||||
L.tileLayer(SETTINGS.maptileurls[getStorage("mapsource")].url, {
|
L.tileLayer(SETTINGS.maptileurls[mapsource].url, {
|
||||||
minZoom: 1,
|
minZoom: 1,
|
||||||
maxZoom: 19
|
maxZoom: 19
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
@ -10,17 +10,27 @@ var firstload = true;
|
|||||||
|
|
||||||
function mapboxMap() {
|
function mapboxMap() {
|
||||||
|
|
||||||
|
var mapsource = "auto";
|
||||||
|
|
||||||
if (getStorage("mapsource") == null) {
|
if (getStorage("mapsource") == null) {
|
||||||
setStorage("mapsource", "liberty");
|
setStorage("mapsource", "auto");
|
||||||
|
}
|
||||||
|
mapsource = getStorage("mapsource");
|
||||||
|
|
||||||
|
if (mapsource == "auto") {
|
||||||
|
if ($("#app").hasClass("theme-dark")) {
|
||||||
|
mapsource = "libertydark";
|
||||||
|
} else {
|
||||||
|
mapsource = "liberty";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#mapbox").css("background-color", SETTINGS.maptileurls[getStorage("mapsource")].bgcolor);
|
$("#mapbox").css("background-color", SETTINGS.maptileurls[mapsource].bgcolor);
|
||||||
|
|
||||||
mapboxgl.accessToken = SETTINGS.mapboxpublictoken;
|
mapboxgl.accessToken = SETTINGS.mapboxpublictoken;
|
||||||
var map = new mapboxgl.Map({
|
var map = new mapboxgl.Map({
|
||||||
container: 'mapbox',
|
container: 'mapbox',
|
||||||
style: SETTINGS.maptileurls[getStorage("mapsource")].json,
|
style: SETTINGS.maptileurls[mapsource].json,
|
||||||
//attributionControl: false,
|
|
||||||
dragPan: true,
|
dragPan: true,
|
||||||
pitch: 0,
|
pitch: 0,
|
||||||
zoom: 2,
|
zoom: 2,
|
||||||
|
@ -691,7 +691,13 @@ var routes = [
|
|||||||
path: '/maps',
|
path: '/maps',
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
async: function (routeTo, routeFrom, resolve, reject) {
|
async: function (routeTo, routeFrom, resolve, reject) {
|
||||||
var mapstyles = [];
|
var mapstyles = [
|
||||||
|
{
|
||||||
|
value: "auto",
|
||||||
|
label: "Auto",
|
||||||
|
selected: !inStorage("mapsource") || getStorage("mapsource") == "auto"
|
||||||
|
}
|
||||||
|
];
|
||||||
for (var id in SETTINGS.maptileurls) {
|
for (var id in SETTINGS.maptileurls) {
|
||||||
if (SETTINGS.maptileurls.hasOwnProperty(id)) {
|
if (SETTINGS.maptileurls.hasOwnProperty(id)) {
|
||||||
mapstyles.push({
|
mapstyles.push({
|
||||||
@ -859,21 +865,21 @@ var routes = [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
settings.push({
|
settings.push({
|
||||||
setting: "showhelp",
|
setting: "showhelp",
|
||||||
title: "Show help",
|
title: "Show help",
|
||||||
text: "Show the <span class=material-icons-intext><i class=material-icons>help</i></span> icons",
|
text: "Show the <span class=material-icons-intext><i class=material-icons>help</i></span> icons",
|
||||||
toggle: true,
|
toggle: true,
|
||||||
checked: getStorage("show_help") != "false",
|
checked: getStorage("show_help") != "false",
|
||||||
onclick: ""
|
onclick: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
setting: "oldhomeui",
|
setting: "oldhomeui",
|
||||||
title: "Show home screen as list",
|
title: "Show home screen as list",
|
||||||
text: "Use a vertical list instead of tiles.",
|
text: "Use a vertical list instead of tiles.",
|
||||||
toggle: true,
|
toggle: true,
|
||||||
checked: getStorage("oldhomeui") == "true",
|
checked: getStorage("oldhomeui") == "true",
|
||||||
onclick: ""
|
onclick: ""
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
resolve({
|
resolve({
|
||||||
templateUrl: './pages/settings.html'
|
templateUrl: './pages/settings.html'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user