mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
viewer: allow showing the light layer
This commit is contained in:
parent
9e0bbcf685
commit
cca2ec58fb
1 changed files with 13 additions and 3 deletions
|
@ -1,7 +1,8 @@
|
||||||
var MinedMapLayer = L.GridLayer.extend({
|
var MinedMapLayer = L.GridLayer.extend({
|
||||||
initialize: function (info, regions) {
|
initialize: function (info, regions, layer) {
|
||||||
this._info = info;
|
this._info = info;
|
||||||
this._regions = regions;
|
this._regions = regions;
|
||||||
|
this._layer = layer;
|
||||||
|
|
||||||
this.options.attribution = 'Generated by <a href="http://git.universe-factory.net/MinedMap/">MinedMap</a>';
|
this.options.attribution = 'Generated by <a href="http://git.universe-factory.net/MinedMap/">MinedMap</a>';
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ var MinedMapLayer = L.GridLayer.extend({
|
||||||
if (coords.x >= this._info.minX && coords.x <= this._info.maxX &&
|
if (coords.x >= this._info.minX && coords.x <= this._info.maxX &&
|
||||||
coords.y >= this._info.minZ && coords.y <= this._info.maxZ &&
|
coords.y >= this._info.minZ && coords.y <= this._info.maxZ &&
|
||||||
this._regions[coords.y-this._info.minZ][coords.x-this._info.minX])
|
this._regions[coords.y-this._info.minZ][coords.x-this._info.minX])
|
||||||
tile.src = 'data/map/0/r.'+coords.x+'.'+coords.y+'.png';
|
tile.src = 'data/'+this._layer+'/0/r.'+coords.x+'.'+coords.y+'.png';
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
},
|
},
|
||||||
|
@ -85,7 +86,16 @@ window.createMap = function () {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
(new MinedMapLayer(info, regions)).addTo(map);
|
var mapLayer = new MinedMapLayer(info, regions, 'map');
|
||||||
|
var lightLayer = new MinedMapLayer(info, regions, 'light');
|
||||||
|
|
||||||
|
mapLayer.addTo(map);
|
||||||
|
|
||||||
|
var overlayMaps = {
|
||||||
|
"Illumination": lightLayer,
|
||||||
|
};
|
||||||
|
|
||||||
|
L.control.layers({}, overlayMaps).addTo(map);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.open('GET', 'data/info.json', true);
|
xhr.open('GET', 'data/info.json', true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue