From cca2ec58fbf2796347aa7ca4b5c1805b736face2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 3 Feb 2015 13:17:36 +0100 Subject: viewer: allow showing the light layer --- viewer/MinedMap.js | 16 +++++++++++++--- 1 file 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 MinedMap'; @@ -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); -- cgit v1.2.3