Skip to content

Commit

Permalink
openstmap: fix if no map
Browse files Browse the repository at this point in the history
Display message if no map is installed
  • Loading branch information
nxdefiant committed Nov 30, 2023
1 parent e5ebb03 commit e96ffad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion apps/openstmap/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion apps/openstmap/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
2 changes: 1 addition & 1 deletion apps/openstmap/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions apps/openstmap/openstmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e96ffad

Please sign in to comment.