world info display

This commit is contained in:
Thomas Rudin 2019-02-04 21:25:30 +01:00
parent d1a71d3a2a
commit c4c8c7699a
3 changed files with 26 additions and 0 deletions

View File

@ -27,6 +27,7 @@
<script src="js/WebSocketChannel.js"></script>
<script src="js/RealtimeTileLayer.js"></script>
<script src="js/CoordinatesDisplay.js"></script>
<script src="js/WorldInfoDisplay.js"></script>
<!-- overlays -->
<script src="js/overlays/TravelnetOverlay.js"></script>

View File

@ -0,0 +1,22 @@
'use strict';
// coord display
var WorldInfoDisplay = L.Control.extend({
initialize: function(wsChannel, opts) {
L.Control.prototype.initialize.call(this, opts);
this.wsChannel = wsChannel;
},
onAdd: function(map) {
var div = L.DomUtil.create('div', 'leaflet-bar leaflet-custom-display');
this.wsChannel.addListener("minetest-info", function(info){
div.innerHTML = "Lag: " + parseInt(info.max_lag*10)/10 + " Time: " + parseInt(info.time)/1000;
});
return div;
},
onRemove: function(map) {
}
});

View File

@ -41,6 +41,9 @@ api.getConfig().then(function(cfg){
var el = new CoordinatesDisplay({ position: 'bottomleft' });
el.addTo(map);
el = new WorldInfoDisplay(wsChannel, { position: 'bottomright' });
el.addTo(map);
}).catch(function(e){
console.error(e);
});