2019-02-01 14:46:38 +03:00
|
|
|
'use strict';
|
2019-01-20 21:50:24 +03:00
|
|
|
|
2019-02-01 14:46:38 +03:00
|
|
|
api.getConfig().then(function(cfg){
|
2019-01-20 21:50:24 +03:00
|
|
|
|
2019-02-01 14:46:38 +03:00
|
|
|
var wsChannel = new WebSocketChannel();
|
|
|
|
wsChannel.connect();
|
2019-01-29 23:07:29 +03:00
|
|
|
|
2019-02-01 14:46:38 +03:00
|
|
|
var initialZoom = 11;
|
|
|
|
var initialCenter = [0, 0];
|
2019-01-22 22:19:04 +03:00
|
|
|
|
2019-02-01 14:46:38 +03:00
|
|
|
var map = L.map('image-map', {
|
|
|
|
minZoom: 2,
|
|
|
|
maxZoom: 12,
|
|
|
|
center: initialCenter,
|
|
|
|
zoom: initialZoom,
|
2019-02-01 15:20:50 +03:00
|
|
|
crs: SimpleCRS
|
2019-02-01 14:46:38 +03:00
|
|
|
});
|
2019-01-29 20:00:00 +03:00
|
|
|
|
2019-02-02 19:28:35 +03:00
|
|
|
map.attributionControl.addAttribution('<a href="https://github.com/thomasrudin-mt/mapserver">Minetest Mapserver</a>');
|
2019-01-29 20:08:54 +03:00
|
|
|
|
2019-02-01 14:46:38 +03:00
|
|
|
var layers = {};
|
|
|
|
var overlays = {}
|
2019-01-20 21:50:24 +03:00
|
|
|
|
2019-02-01 15:20:50 +03:00
|
|
|
var layerMgr = new LayerManager(cfg.layers, map);
|
|
|
|
|
|
|
|
var tileLayer = new RealtimeTileLayer(wsChannel, 0);
|
2019-02-01 14:46:38 +03:00
|
|
|
tileLayer.addTo(map);
|
2019-01-20 21:50:24 +03:00
|
|
|
|
2019-02-07 09:56:52 +03:00
|
|
|
//TODO: all layers
|
2019-02-01 14:46:38 +03:00
|
|
|
layers["Base"] = tileLayer;
|
2019-02-07 09:56:52 +03:00
|
|
|
|
|
|
|
overlays["Player"] = new PlayerOverlay(wsChannel, layerMgr);
|
|
|
|
overlays["POI"] = new PoiOverlay(wsChannel, layerMgr);
|
2019-02-01 15:20:50 +03:00
|
|
|
overlays["Travelnet"] = new TravelnetOverlay(wsChannel, layerMgr);
|
2019-02-08 10:27:10 +03:00
|
|
|
overlays["Bones"] = new BonesOverlay(wsChannel, layerMgr);
|
2019-02-08 10:48:34 +03:00
|
|
|
overlays["Digilines LCD"] = new LcdOverlay(wsChannel, layerMgr);
|
2019-02-08 12:07:59 +03:00
|
|
|
overlays["Digiterms"] = new DigitermOverlay(wsChannel, layerMgr);
|
|
|
|
overlays["Lua Controller"] = new LuacontrollerOverlay(wsChannel, layerMgr);
|
2019-02-08 12:13:27 +03:00
|
|
|
overlays["Technic Anchor"] = new TechnicAnchorOverlay(wsChannel, layerMgr);
|
2019-02-07 22:06:09 +03:00
|
|
|
//overlays["Protector"] = new ProtectorOverlay(wsChannel, layerMgr);
|
2019-01-29 20:08:54 +03:00
|
|
|
|
2019-02-08 10:27:10 +03:00
|
|
|
//Default enabled overlays
|
2019-02-07 21:01:00 +03:00
|
|
|
map.addLayer(overlays["Player"]);
|
2019-02-08 10:27:10 +03:00
|
|
|
map.addLayer(overlays["POI"]);
|
2019-02-05 23:17:14 +03:00
|
|
|
|
2019-02-01 14:46:38 +03:00
|
|
|
L.control.layers(layers, overlays).addTo(map);
|
2019-01-20 21:50:24 +03:00
|
|
|
|
2019-02-07 09:56:52 +03:00
|
|
|
new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map);
|
|
|
|
new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map);
|
2019-02-04 23:25:30 +03:00
|
|
|
|
2019-02-04 23:15:00 +03:00
|
|
|
}).catch(function(e){
|
|
|
|
console.error(e);
|
2019-02-01 14:46:38 +03:00
|
|
|
});
|