Minor fixes

This commit is contained in:
Felix Niederwanger 2021-05-24 18:11:39 +02:00
parent 44acfeaf0f
commit 93f4ae4beb
Signed by: phoenix
GPG key ID: 6E77A590E3F6D71C
2 changed files with 9 additions and 10 deletions

View file

@ -22,12 +22,15 @@ var mqtt MQTTReceiver
var devices map[string]Location
func (c *Config) SetDefaults() {
c.wwwDir = ""
c.wwwDir = "./www"
c.bindAddr = "127.0.0.1:8090"
c.mqttRemote = ""
c.mqttRemote = "127.0.0.1"
}
func mqtt_recv(id string, loc Location) {
if !loc.IsPlausible() { // Ignore stupid locations
return
}
devices[id] = loc
}

View file

@ -13,14 +13,9 @@ L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
var doFitBounds = true;
function refresh(e) {
var coordPart = function(v, dirs) {
return dirs.charAt(v >= 0 ? 0 : 1) +
(Math.round(Math.abs(v) * 100) / 100).toString();
},
popupContent = function(fId) {
var feature = e.features[fId],
c = feature.geometry.coordinates;
return feature.properties['name' ] + ' at ' + coordPart(c[1], 'NS') + ', ' + coordPart(c[0], 'EW');
var popupContent = function(fId) {
var feature = e.features[fId];
return feature.properties['name' ];
},
bindFeaturePopup = function(fId) {
realtime.getLayer(fId).bindPopup(popupContent(fId));
@ -29,6 +24,7 @@ function refresh(e) {
realtime.getLayer(fId).getPopup().setContent(popupContent(fId));
};
// Refresh only once at the beginning
if (doFitBounds) {
map.fitBounds(realtime.getBounds(), {maxZoom: 15});
doFitBounds = false;