mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
viewer: center on spawn
This commit is contained in:
parent
34857eabbc
commit
43a9df351a
1 changed files with 11 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
var MinedMapLayer = L.GridLayer.extend({
|
var MinedMapLayer = L.GridLayer.extend({
|
||||||
initialize: function (info) {
|
initialize: function (info, regions) {
|
||||||
this._info = info.info;
|
this._info = info;
|
||||||
this._regions = info.regions;
|
this._regions = regions;
|
||||||
|
|
||||||
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>';
|
||||||
|
|
||||||
|
@ -68,21 +68,24 @@ var MinedMapLayer = L.GridLayer.extend({
|
||||||
window.createMap = function () {
|
window.createMap = function () {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onload = function () {
|
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', {
|
var map = L.map('map', {
|
||||||
center: [0, 0],
|
center: [-spawn.z, spawn.x],
|
||||||
zoom: 0,
|
zoom: 0,
|
||||||
minZoom: 0,
|
minZoom: 0,
|
||||||
maxZoom: 3,
|
maxZoom: 3,
|
||||||
crs: L.CRS.Simple,
|
crs: L.CRS.Simple,
|
||||||
maxBounds: [
|
maxBounds: [
|
||||||
[-512*(info.info.maxZ+1), 512*info.info.minX],
|
[-512*(info.maxZ+1), 512*info.minX],
|
||||||
[-512*info.info.minZ, 512*(info.info.maxX+1)],
|
[-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);
|
xhr.open('GET', 'data/info.json', true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue