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 rtTiles = new RealtimeTileLayer(wsChannel);
|
2019-01-20 21:50:24 +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-01 14:46:38 +03:00
|
|
|
layers["Base"] = tileLayer;
|
2019-02-01 15:20:50 +03:00
|
|
|
overlays["Travelnet"] = new TravelnetOverlay(wsChannel, layerMgr);
|
2019-01-29 20:08:54 +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-01 14:58:26 +03:00
|
|
|
var el = new CoordinatesDisplay({ position: 'bottomleft' });
|
2019-02-01 14:46:38 +03:00
|
|
|
el.addTo(map);
|
2019-01-20 21:50:24 +03:00
|
|
|
|
2019-02-01 14:46:38 +03:00
|
|
|
});
|