1
0
forked from MTSR/mapserver
mapserver/server/static/js/map.js

36 lines
951 B
JavaScript
Raw Normal View History

2019-06-11 15:16:41 +03:00
export function setup(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 overlays = {};
window.layerMgr = new LayerManager(wsChannel, cfg.layers, map, Hashroute.getLayerId());
//All overlays
Overlaysetup(cfg, map, overlays, wsChannel, layerMgr);
new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map);
new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map);
if (cfg.enablesearch){
new SearchControl(wsChannel, { position: 'topright' }).addTo(map);
}
//layer control
L.control.layers(layerMgr.layerObjects, overlays, { position: "topright" }).addTo(map);
Hashroute.setup(map, layerMgr);
}