Closed andibraeu closed 5 years ago
https://github.com/freifunk-berlin/firmware/issues/488 is also mentioning that the map seems broken since some time.
As nobody took care of it, to make it work again, it seems not relevant for the users.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""
/>
<script
src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"
integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="
crossorigin=""
>
</script>
<title>Map</title>
</head>
<body style="margin:0">
<div id="ffmap" style="position:relative; width:100%; height:640px;"></div>
<script type="text/javascript">
var INFINITE = 99.99;
var map = L.map('ffmap').setView([52.48, 12], 13);
var osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
var osm = new L.TileLayer(osmUrl, {attribution: osmAttrib});
map.addLayer(osm);
var alias = new Array;
var points = new Array;
var unkpos = new Array;
var lineid = 0;
onload=new Function("if(null!=window.ffmapinit)ffmapinit();");
function Mid(mainip, aliasip)
{
alias[aliasip]=mainip;
}
function Node(mainip,lat,lon,ishna,hnaip,name)
{
points[mainip] = [lat, lon];
var marker = L.circleMarker([lat, lon]).addTo(map);
marker.bindPopup(
'Node: '+ name
+
'<br>IP: '+ mainip
+ '<br>DefGW: '+ hnaip
);
}
function Self(mainip,lat,lon,ishna,hnaip,name)
{
//map.LoadMap(new VELatLong(lat, lon), 15, VEMapStyle.Hybrid);
//map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
//map.ShowMiniMap(14, 474);
Node(mainip,lat,lon,ishna,hnaip,name);
map.setView([lat, lon], 13)
}
function Link(fromip,toip,lq,nlq,etx)
{
if (0==lineid && null!=window.ffmapstatic) ffmapstatic();
if (null != alias[toip]) toip = alias[toip];
if (null != alias[fromip]) fromip = alias[fromip];
if (null != points[fromip] && null != points[toip])
{
var color;
var red = 240;
var green = 0;
var blue = 0;
var w = 1
if (etx < 100) {red=252;green=102;blue=0;w=2};
if (etx < 10) {red=255;green=203;blue=5;w=3};
if (etx < 4) {red=240;green=255;blue=0;w=4};
if (etx < 2) {red=0;green=204;blue=0;w=5};
if (etx < 1) {red=80;green=0;blue=0;w=1};
var polyline = L.polyline([points[fromip], points[toip]], {color:
'rgb(' + red + ', ' + green + ', ' + blue + ')'})
.addTo(map);
polyline.bindPopup(
fromip + " - " + toip + "<br>"
+ "ETX: " + etx + "<br>"
+ "LQ: " + lq + "<br>"
+ "NLQ: " + nlq + "<br>"
);
}
else
{
if (null == points[toip]) unkpos[toip] = '';
if (null == points[fromip]) unkpos[fromip] = '';
}
lineid++;
}
function PLink(fromip,toip,lq,nlq,etx,lata,lona,ishnaa,latb,lonb,ishnab)
{
Link(fromip,toip,lq,nlq,etx);
}
function ffmapinit()
{
<%
local fd
local uci = require "luci.model.uci".cursor()
uci:foreach("olsrd", "LoadPlugin", function(s)
if s.library == "olsrd_nameservice.so.0.3" and s.latlon_file then
fd = io.open(s.latlon_file)
end
end)
if fd then
local data = fd:read("*a")
fd:close()
if data then
local line
for line in data:gmatch("[^\n]+") do
if line:match(";$") then
write(line .. "\n")
else
break
end
end
end
end
%>
}
</script>
</body>
</html>
Copying this to /usr/lib/lua/luci/view/freifunk-map/map.htm
should create a working but ugly live map based on leaflet and openstreetmap tiles.
Let's take a look on that, maybe we find a frontend god to make it beautiful
it doesn't look that bad...
@andibraeu as the OWM-app seems broken, I came onto this PR again. It seems that you had some working code (22bb9b7) can you push this as PR? I had a closer look at the code and realized that it's not relying on the OWM-data but just on the local olsr-data of the host.
it was part of this PR: https://github.com/freifunk/openwrt-packages/pull/18
Thanks to the "restore deleted branch" feature of a PR the commits have been found again.
we could move to bing maps v8, but to use it users need to get an API key. So it would be best to remove this kind of map.