summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-02-02 18:39:44 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-02-02 18:39:44 +0100
commit43a9df351ac3c69bcd19e8dbb84583181f59ee22 (patch)
tree593ff07c99d9c97e9cbeecebbdb7845e3ca5e282
parent34857eabbcaea2344fe7912f96fbd7f854c37e1b (diff)
downloadMinedMap-43a9df351ac3c69bcd19e8dbb84583181f59ee22.tar
MinedMap-43a9df351ac3c69bcd19e8dbb84583181f59ee22.zip
viewer: center on spawn
-rw-r--r--viewer/MinedMap.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/viewer/MinedMap.js b/viewer/MinedMap.js
index 17a31cb..959e3ed 100644
--- a/viewer/MinedMap.js
+++ b/viewer/MinedMap.js
@@ -1,7 +1,7 @@
var MinedMapLayer = L.GridLayer.extend({
- initialize: function (info) {
- this._info = info.info;
- this._regions = info.regions;
+ initialize: function (info, regions) {
+ this._info = info;
+ this._regions = regions;
this.options.attribution = 'Generated by <a href="http://git.universe-factory.net/MinedMap/">MinedMap</a>';
@@ -68,21 +68,24 @@ var MinedMapLayer = L.GridLayer.extend({
window.createMap = function () {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
- var info = JSON.parse(this.responseText);
+ var res = JSON.parse(this.responseText),
+ info = res.info,
+ regions = res.regions,
+ spawn = res.spawn;
var map = L.map('map', {
- center: [0, 0],
+ center: [-spawn.z, spawn.x],
zoom: 0,
minZoom: 0,
maxZoom: 3,
crs: L.CRS.Simple,
maxBounds: [
- [-512*(info.info.maxZ+1), 512*info.info.minX],
- [-512*info.info.minZ, 512*(info.info.maxX+1)],
+ [-512*(info.maxZ+1), 512*info.minX],
+ [-512*info.minZ, 512*(info.maxX+1)],
],
});
- (new MinedMapLayer(info)).addTo(map);
+ (new MinedMapLayer(info, regions)).addTo(map);
};
xhr.open('GET', 'data/info.json', true);