mapserver/static/js/map/MapFactory.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

import wsChannel from '../WebSocketChannel.js';
import SimpleCRS from './SimpleCRS.js';
import CoordinatesDisplay from './CoordinatesDisplay.js';
import WorldInfoDisplay from './WorldInfoDisplay.js';
2019-09-18 12:53:58 +03:00
import TopRightControl from './TopRightControl.js';
import Overlaysetup from './Overlaysetup.js';
import CustomOverlay from './CustomOverlay.js';
2019-09-18 12:53:58 +03:00
import RealtimeTileLayer from './RealtimeTileLayer.js';
import config from '../config.js';
export function createMap(node, layerId, zoom, lat, lon){
const cfg = config.get();
const map = L.map(node, {
minZoom: 2,
maxZoom: 12,
center: [lat, lon],
zoom: zoom,
crs: SimpleCRS
});
map.attributionControl.addAttribution('<a href="https://github.com/minetest-tools/mapserver">Minetest Mapserver</a>');
2019-09-18 12:53:58 +03:00
var tileLayer = new RealtimeTileLayer(wsChannel, layerId, map);
tileLayer.addTo(map);
//All overlays
2019-09-18 12:53:58 +03:00
var overlays = {};
Overlaysetup(cfg, map, overlays);
CustomOverlay(map, overlays);
new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map);
new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map);
2019-09-18 12:53:58 +03:00
new TopRightControl({ position: 'topright' }).addTo(map);
2019-09-18 09:42:11 +03:00
//layer control
2019-09-18 12:53:58 +03:00
L.control.layers({}, overlays, { position: "topright" }).addTo(map);
return map;
}