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 map = L.map('image-map', {
|
|
|
|
minZoom: 2,
|
|
|
|
maxZoom: 12,
|
2019-02-15 17:51:11 +03:00
|
|
|
center: Hashroute.getCenter(),
|
|
|
|
zoom: Hashroute.getZoom(),
|
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);
|
2019-02-15 17:51:11 +03:00
|
|
|
layerMgr.setLayerId( Hashroute.getLayerId() );
|
2019-02-01 15:20:50 +03:00
|
|
|
|
2019-02-15 14:47:43 +03:00
|
|
|
//All layers
|
|
|
|
cfg.layers.forEach(function(layer){
|
2019-03-13 23:28:14 +03:00
|
|
|
var tileLayer = new RealtimeTileLayer(wsChannel, layer.id, map);
|
2019-02-15 14:47:43 +03:00
|
|
|
layers[layer.name] = tileLayer;
|
|
|
|
});
|
2019-02-14 16:16:32 +03:00
|
|
|
|
2019-03-01 09:29:17 +03:00
|
|
|
//current layer
|
2019-03-13 23:28:14 +03:00
|
|
|
var currentLayer = layerMgr.getCurrentLayer();
|
|
|
|
layers[currentLayer.name].addTo(map);
|
2019-03-01 09:29:17 +03:00
|
|
|
|
2019-02-15 14:47:43 +03:00
|
|
|
//All overlays
|
|
|
|
Overlaysetup(cfg, map, overlays, wsChannel, layerMgr);
|
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-15 17:51:11 +03:00
|
|
|
Hashroute.setup(map, layerMgr);
|
|
|
|
|
2019-02-04 23:15:00 +03:00
|
|
|
}).catch(function(e){
|
|
|
|
console.error(e);
|
2019-02-01 14:46:38 +03:00
|
|
|
});
|