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

48 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-01-20 21:50:24 +03:00
(function(){
var crs = L.Util.extend({}, L.CRS.Simple, {
//transformation: L.transformation(0.001, 0, -0.001, 0),
scale: function (zoom) {
return Math.pow(2, zoom-9);
}
});
var initialZoom = 11;
var initialCenter = [0, 0];
var map = L.map('image-map', {
minZoom: 2,
maxZoom: 12,
center: initialCenter,
zoom: initialZoom,
crs: crs
});
2019-01-22 22:19:04 +03:00
var wsUrl = location.protocol.replace("http", "ws") + "//" + location.host + location.pathname.substring(0, location.pathname.lastIndexOf("/")) + "/api/ws";
var ws = new WebSocket(wsUrl);
ws.onmessage = function(e){
var event = JSON.parse(e.data);
if (event.type == "rendered-tile"){
2019-01-29 10:36:46 +03:00
realtimelayer.update(event.data)
2019-01-22 22:19:04 +03:00
}
}
2019-01-20 21:50:24 +03:00
var layers = {};
2019-01-29 10:36:46 +03:00
var Layer = realtimelayer.create(0);
2019-01-20 21:50:24 +03:00
var tileLayer = new Layer();
tileLayer.addTo(map);
L.control.layers(layers, {}).addTo(map);
var el = L.control.coordinatesDisplay({ position: 'bottomleft' });
el.addTo(map);
})()