openstmap: sort maps by scale desc

This results in the map with the highest resolution (lowest scale) to be
drawn last
master
Erik Andresen 2023-06-28 11:08:19 +02:00
parent 4dd4a17511
commit bf58db6a31
4 changed files with 5 additions and 3 deletions

View File

@ -19,3 +19,4 @@
0.16: Draw waypoints, too.
0.17: With new Recorder app allow track to be drawn in the background
Switch tile layer URL for faster/more reliable map tiles
0.18: Prefer map with highest resolution

View File

@ -183,7 +183,7 @@ TODO:
}).addTo(map);
let marker = new L.marker(latlon).addTo(map);
map.fitBounds(latlon.toBounds(2000/*meters*/), {animation: false});
}, 100);
}, 500);
}
resolve();
});

View File

@ -2,7 +2,7 @@
"id": "openstmap",
"name": "OpenStreetMap",
"shortName": "OpenStMap",
"version": "0.17",
"version": "0.18",
"description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps",
"readme": "README.md",
"icon": "app.png",

View File

@ -30,6 +30,7 @@ m.maps = require("Storage").list(/openstmap\.\d+\.json/).map(f=>{
map.center = Bangle.project({lat:map.lat,lon:map.lon});
return map;
});
m.maps.sort((a,b) => b.scale-a.scale); // sort by scale so highest resolution is drawn last
// we base our start position on the middle of the first map
m.map = m.maps[0];
m.scale = m.map.scale; // current scale (based on first map)