diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-03 13:17:36 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-03 13:17:36 +0100 |
commit | cca2ec58fbf2796347aa7ca4b5c1805b736face2 (patch) | |
tree | 71222d7bb5ca8514bff9bdba6a46a9ea56bc2f70 | |
parent | 9e0bbcf685786e21b7d61216f4e1a24f0b1a3354 (diff) | |
download | MinedMap-cca2ec58fbf2796347aa7ca4b5c1805b736face2.tar MinedMap-cca2ec58fbf2796347aa7ca4b5c1805b736face2.zip |
viewer: allow showing the light layer
-rw-r--r-- | viewer/MinedMap.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/viewer/MinedMap.js b/viewer/MinedMap.js index ad330b2..c8a41df 100644 --- a/viewer/MinedMap.js +++ b/viewer/MinedMap.js @@ -1,7 +1,8 @@ var MinedMapLayer = L.GridLayer.extend({ - initialize: function (info, regions) { + initialize: function (info, regions, layer) { this._info = info; this._regions = regions; + this._layer = layer; 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 && coords.y >= this._info.minZ && coords.y <= this._info.maxZ && 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; }, @@ -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); |