Minor fixes
This commit is contained in:
parent
44acfeaf0f
commit
93f4ae4beb
|
@ -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
|
||||
}
|
||||
|
||||
|
|
12
www/index.js
12
www/index.js
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue