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

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-04-04 11:19:29 +03:00
/* jshint undef: false */
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-04-04 11:19:29 +03:00
var overlays = {};
2019-01-20 21:50:24 +03:00
2019-04-21 22:51:43 +03:00
window.layerMgr = new LayerManager(wsChannel, 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 overlays
Overlaysetup(cfg, map, overlays, wsChannel, layerMgr);
2019-02-05 23:17:14 +03:00
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
if (cfg.enablesearch){
new SearchControl(wsChannel, { position: 'topright' }).addTo(map);
}
//layer control
2019-04-21 22:51:43 +03:00
L.control.layers(layerMgr.layerObjects, overlays, { position: "topright" }).addTo(map);
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
});