mapserver/server/static/js/main.js
NatureFreshMilk 320d099a2c hash route
2019-02-15 15:51:11 +01:00

45 lines
1.0 KiB
JavaScript

'use strict';
api.getConfig().then(function(cfg){
var wsChannel = new WebSocketChannel();
wsChannel.connect();
var map = L.map('image-map', {
minZoom: 2,
maxZoom: 12,
center: Hashroute.getCenter(),
zoom: Hashroute.getZoom(),
crs: SimpleCRS
});
map.attributionControl.addAttribution('<a href="https://github.com/thomasrudin-mt/mapserver">Minetest Mapserver</a>');
var layers = {};
var overlays = {}
var layerMgr = new LayerManager(cfg.layers, map);
layerMgr.setLayerId( Hashroute.getLayerId() );
//All layers
cfg.layers.forEach(function(layer){
var tileLayer = new RealtimeTileLayer(wsChannel, layer.id);
tileLayer.addTo(map);
layers[layer.name] = tileLayer;
});
//All overlays
Overlaysetup(cfg, map, overlays, wsChannel, layerMgr);
L.control.layers(layers, overlays).addTo(map);
new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map);
new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map);
Hashroute.setup(map, layerMgr);
}).catch(function(e){
console.error(e);
});