mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
viewer: do not show sign layer when the feature is disabled
This commit is contained in:
parent
625f2a13a3
commit
08f84fa339
1 changed files with 23 additions and 18 deletions
|
@ -338,7 +338,8 @@ window.createMap = function () {
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
const res = JSON.parse(this.responseText),
|
const res = JSON.parse(this.responseText),
|
||||||
mipmaps = res.mipmaps,
|
mipmaps = res.mipmaps,
|
||||||
spawn = res.spawn;
|
spawn = res.spawn,
|
||||||
|
features = res.features || {};
|
||||||
|
|
||||||
const updateParams = function () {
|
const updateParams = function () {
|
||||||
const args = parseHash();
|
const args = parseHash();
|
||||||
|
@ -356,7 +357,7 @@ window.createMap = function () {
|
||||||
params.x = spawn.x;
|
params.x = spawn.x;
|
||||||
if (isNaN(params.z))
|
if (isNaN(params.z))
|
||||||
params.z = spawn.z;
|
params.z = spawn.z;
|
||||||
if (isNaN(params.marker[0]) || isNaN(params.marker[1]))
|
if (!features.signs || isNaN(params.marker[0]) || isNaN(params.marker[1]))
|
||||||
params.marker = null;
|
params.marker = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -374,23 +375,25 @@ window.createMap = function () {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const overlayMaps = {};
|
||||||
|
|
||||||
const mapLayer = new MinedMapLayer(mipmaps, 'map');
|
const mapLayer = new MinedMapLayer(mipmaps, 'map');
|
||||||
const lightLayer = new MinedMapLayer(mipmaps, 'light');
|
|
||||||
const signLayer = L.layerGroup();
|
|
||||||
|
|
||||||
loadSigns(signLayer);
|
|
||||||
|
|
||||||
mapLayer.addTo(map);
|
mapLayer.addTo(map);
|
||||||
|
|
||||||
|
const lightLayer = new MinedMapLayer(mipmaps, 'light');
|
||||||
|
overlayMaps['Illumination'] = lightLayer;
|
||||||
if (params.light)
|
if (params.light)
|
||||||
map.addLayer(lightLayer);
|
map.addLayer(lightLayer);
|
||||||
if (params.signs)
|
|
||||||
map.addLayer(signLayer);
|
|
||||||
|
|
||||||
const overlayMaps = {
|
let signLayer;
|
||||||
"Illumination": lightLayer,
|
if (features.signs) {
|
||||||
"Signs": signLayer,
|
signLayer = L.layerGroup();
|
||||||
};
|
loadSigns(signLayer);
|
||||||
|
if (params.signs)
|
||||||
|
map.addLayer(signLayer);
|
||||||
|
|
||||||
|
overlayMaps['Signs'] = signLayer;
|
||||||
|
}
|
||||||
|
|
||||||
L.control.layers({}, overlayMaps).addTo(map);
|
L.control.layers({}, overlayMaps).addTo(map);
|
||||||
|
|
||||||
|
@ -409,7 +412,7 @@ window.createMap = function () {
|
||||||
|
|
||||||
if (map.hasLayer(lightLayer))
|
if (map.hasLayer(lightLayer))
|
||||||
ret += '&light=1';
|
ret += '&light=1';
|
||||||
if (!map.hasLayer(signLayer))
|
if (features.signs && !map.hasLayer(signLayer))
|
||||||
ret += '&signs=0';
|
ret += '&signs=0';
|
||||||
if (params.marker) {
|
if (params.marker) {
|
||||||
ret += `&marker=${params.marker[0]},${params.marker[1]}`;
|
ret += `&marker=${params.marker[0]},${params.marker[1]}`;
|
||||||
|
@ -456,10 +459,12 @@ window.createMap = function () {
|
||||||
map.addLayer(lightLayer);
|
map.addLayer(lightLayer);
|
||||||
else
|
else
|
||||||
map.removeLayer(lightLayer);
|
map.removeLayer(lightLayer);
|
||||||
if (params.signs)
|
if (features.signs) {
|
||||||
map.addLayer(signLayer);
|
if (params.signs)
|
||||||
else
|
map.addLayer(signLayer);
|
||||||
map.removeLayer(signLayer);
|
else
|
||||||
|
map.removeLayer(signLayer);
|
||||||
|
}
|
||||||
|
|
||||||
updateHash();
|
updateHash();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue