[TASK] Automatic map switch based on time
This commit is contained in:
parent
d1017cca12
commit
2c80712fb9
56
lib/map.js
56
lib/map.js
@ -132,10 +132,42 @@ define(["map/clientlayer", "map/labelslayer",
|
||||
});
|
||||
}
|
||||
|
||||
var iconOnline = {color: "#1566A9", fillColor: "#1566A9", radius: 6, fillOpacity: 0.5, opacity: 0.5, weight: 2, className: "stroke-first"};
|
||||
var iconOffline = {color: "#D43E2A", fillColor: "#D43E2A", radius: 3, fillOpacity: 0.5, opacity: 0.5, weight: 1, className: "stroke-first"};
|
||||
var iconLost = {color: "#D43E2A", fillColor: "#D43E2A", radius: 4, fillOpacity: 0.8, opacity: 0.8, weight: 1, className: "stroke-first"};
|
||||
var iconAlert = {color: "#D43E2A", fillColor: "#D43E2A", radius: 5, fillOpacity: 0.8, opacity: 0.8, weight: 2, className: "stroke-first"};
|
||||
var iconOnline = {
|
||||
color: "#1566A9",
|
||||
fillColor: "#1566A9",
|
||||
radius: 6,
|
||||
fillOpacity: 0.5,
|
||||
opacity: 0.5,
|
||||
weight: 2,
|
||||
className: "stroke-first"
|
||||
};
|
||||
var iconOffline = {
|
||||
color: "#D43E2A",
|
||||
fillColor: "#D43E2A",
|
||||
radius: 3,
|
||||
fillOpacity: 0.5,
|
||||
opacity: 0.5,
|
||||
weight: 1,
|
||||
className: "stroke-first"
|
||||
};
|
||||
var iconLost = {
|
||||
color: "#D43E2A",
|
||||
fillColor: "#D43E2A",
|
||||
radius: 4,
|
||||
fillOpacity: 0.8,
|
||||
opacity: 0.8,
|
||||
weight: 1,
|
||||
className: "stroke-first"
|
||||
};
|
||||
var iconAlert = {
|
||||
color: "#D43E2A",
|
||||
fillColor: "#D43E2A",
|
||||
radius: 5,
|
||||
fillOpacity: 0.8,
|
||||
opacity: 0.8,
|
||||
weight: 2,
|
||||
className: "stroke-first"
|
||||
};
|
||||
var iconNew = {color: "#1566A9", fillColor: "#93E929", radius: 6, fillOpacity: 1.0, opacity: 0.5, weight: 2};
|
||||
|
||||
return function (config, linkScale, sidebar, router, buttons) {
|
||||
@ -241,6 +273,18 @@ define(["map/clientlayer", "map/labelslayer",
|
||||
el.classList.add("map");
|
||||
|
||||
map = L.map(el, options);
|
||||
var now = new Date();
|
||||
config.mapLayers.forEach(function (item, i) {
|
||||
if (item.config.start <= now.getHours() || item.config.end > now.getHours()) {
|
||||
item.config.order = item.config.start * -1;
|
||||
} else {
|
||||
item.config.order = i;
|
||||
}
|
||||
});
|
||||
|
||||
config.mapLayers = config.mapLayers.sort(function (a, b) {
|
||||
return a.config.order - b.config.order;
|
||||
});
|
||||
|
||||
var layers = config.mapLayers.map(function (d) {
|
||||
return {
|
||||
@ -294,8 +338,8 @@ define(["map/clientlayer", "map/labelslayer",
|
||||
if (e.layer.options.mode) {
|
||||
document.querySelector("head").innerHTML += "<link rel='stylesheet' class='css-mode' href='" + e.layer.options.mode + ".css'>";
|
||||
document.querySelector("html").classList.add(e.layer.options.mode);
|
||||
var cssInterval = setInterval(function() {
|
||||
if(document.querySelector(".css-mode").sheet) {
|
||||
var cssInterval = setInterval(function () {
|
||||
if (document.querySelector(".css-mode").sheet) {
|
||||
labelsLayer.updateColor();
|
||||
clearInterval(cssInterval);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user