Skip to content

Commit

Permalink
Allow zooming map in/out by clicking.
Browse files Browse the repository at this point in the history
By simply clicking on screen instead of going to menu to zoom in/out, navigation can be much quicker.
  • Loading branch information
pavelmachek committed Aug 1, 2023
1 parent 4061bd2 commit 5359461
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/openstmap/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Support for zooming in on map
Satellite count moved to widget bar to leave more room for the map
0.15: Make track drawing an option (default off)
0.16: Draw waypoints, too.
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
Expand All @@ -28,3 +28,4 @@
Enable/Disable previous position marker in new setting "Draw cont. position"
0.22: Replace position marker with direction arrow
0.23: Bugfix: Enable Compass if needed
0.24: Allow zooming by clicking the screen
16 changes: 16 additions & 0 deletions apps/openstmap/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var hasScrolled = false;
var settings = require("Storage").readJSON("openstmap.json",1)||{};
var plotTrack;
let checkMapPos = false; // Do we need to check the if the coordinates we have are valid
var startDrag = 0;

if (Bangle.setLCDOverlay) {
// Icon for current location+direction: https://icons8.com/icon/11932/gps 24x24, 1 Bit + transparency + inverted
var imgLoc = require("heatshrink").decompress(atob("jEYwINLAQk8AQl+AQn/AQcB/+AAQUD//AAQUH//gAQUP//wAQUf//4j8AvA9IA=="));
Expand Down Expand Up @@ -235,14 +237,28 @@ function showMap() {
Bangle.setUI({mode:"custom",drag:e=>{
if (plotTrack && plotTrack.stop) plotTrack.stop();
if (e.b) {
if (!startDrag)
startDrag = getTime();
g.setClipRect(R.x,R.y,R.x2,R.y2);
g.scroll(e.dx,e.dy);
m.scroll(e.dx,e.dy);
g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1);
hasScrolled = true;
drawLocation();
} else if (hasScrolled) {
delta = getTime() - startDrag;
startDrag = 0;
hasScrolled = false;
if (delta < 0.2) {
if (e.y > g.getHeight() / 2) {
if (e.x < g.getWidth() / 2) {
m.scale /= 2;
} else {
m.scale *= 2;
}
}

Check failure on line 259 in apps/openstmap/app.js

View workflow job for this annotation

GitHub Actions / build

Mixed spaces and tabs
g.reset().clearRect(R);

Check failure on line 260 in apps/openstmap/app.js

View workflow job for this annotation

GitHub Actions / build

Mixed spaces and tabs
}
redraw();
}
}, btn: () => showMenu() });
Expand Down
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.23",
"version": "0.24",
"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

0 comments on commit 5359461

Please sign in to comment.