1
0
Fork 0

openstmap: fix if no map

Display message if no map is installed
master
Erik Andresen 2023-11-30 21:00:05 +01:00
parent e5ebb03e13
commit e96ffad55f
4 changed files with 14 additions and 6 deletions

View File

@ -30,4 +30,5 @@
0.23: Bugfix: Enable Compass if needed
0.24: Allow zooming by clicking the screen
0.25: Enable scaled image filtering on 2v19+ firmware
0.26: Ensure that when redrawing, we always cancel any in-progress track draw
0.26: Ensure that when redrawing, we always cancel any in-progress track draw
0.27: Display message if no map is installed

View File

@ -268,7 +268,12 @@ function showMap() {
}, btn: () => showMenu() });
}
showMap();
if (m.maps.length === 0) {
E.showPrompt(/*LANG*/'Please upload a map first.', {buttons : {/*LANG*/"Ok":true}}).then(v => load());
} else {
showMap();
}
// Write settings on exit via button
setWatch(() => writeSettings(), BTN, { repeat: true, edge: "rising" });

View File

@ -2,7 +2,7 @@
"id": "openstmap",
"name": "OpenStreetMap",
"shortName": "OpenStMap",
"version": "0.26",
"version": "0.27",
"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

@ -33,9 +33,11 @@ m.maps = require("Storage").list(/openstmap\.\d+\.json/).map(f=>{
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)
m.lat = m.map.lat; // position of middle of screen
m.lon = m.map.lon; // position of middle of screen
if (m.map) {
m.scale = m.map.scale; // current scale (based on first map)
m.lat = m.map.lat; // position of middle of screen
m.lon = m.map.lon; // position of middle of screen
}
// return number of tiles drawn
exports.draw = function() {