mirror of https://github.com/espruino/BangleApps
mylocation: Add option to set location from waypoint
parent
be5fcdd185
commit
73042fa58d
|
@ -7,3 +7,4 @@
|
|||
0.07: Move mylocation app into 'Settings -> Apps'
|
||||
0.08: Allow setting location from webinterface in the AppLoader
|
||||
0.09: Fix web interface so app can be installed (replaced custom with interface html)
|
||||
0.10: Add waypoints as location source
|
||||
|
|
|
@ -9,7 +9,7 @@ next to it - and you can choose your location on a map.
|
|||
|
||||
**On Bangle.js** go to `Settings -> Apps -> My Location`
|
||||
|
||||
* Select one of the preset Cities, setup through the GPS or use the webinterface from the AppLoader
|
||||
* Select one of the preset Cities, setup through the GPS, waypoints or use the webinterface from the AppLoader
|
||||
* Other Apps can read this information to do calculations based on location
|
||||
* When the City shows ??? it means the location has been set through the GPS
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
"icon": "app.png",
|
||||
"type": "settings",
|
||||
"screenshots": [{"url":"screenshot_1.png"}],
|
||||
"version":"0.09",
|
||||
"description": "Sets and stores the latitude and longitude of your preferred City. It can be set from GPS or webinterface. `mylocation.json` can be used by other apps that need your main location. See README for details.",
|
||||
"version":"0.10",
|
||||
"description": "Sets and stores the latitude and longitude of your preferred City. It can be set from GPS, waypoints or webinterface. `mylocation.json` can be used by other apps that need your main location. See README for details.",
|
||||
"readme": "README.md",
|
||||
"tags": "tool,utility",
|
||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||
"interface": "interface.html",
|
||||
"dependencies" : { "waypoints":"type" },
|
||||
"storage": [
|
||||
{"name":"mylocation.settings.js","url":"settings.js"}
|
||||
],
|
||||
|
|
|
@ -13,7 +13,7 @@ let s = {
|
|||
function loadSettings() {
|
||||
settings = require('Storage').readJSON(SETTINGS_FILE, 1) || {};
|
||||
for (const key in settings) {
|
||||
s[key] = settings[key]
|
||||
s[key] = settings[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ function setFromGPS() {
|
|||
//console.log(".");
|
||||
if (gps.fix === 0) return;
|
||||
//console.log("fix from GPS");
|
||||
s = {'lat': gps.lat, 'lon': gps.lon, 'location': '???' };
|
||||
s = {'lat': gps.lat, 'lon': gps.lon, 'location': 'GPS' };
|
||||
Bangle.buzz(1500); // buzz on first position
|
||||
Bangle.setGPSPower(0, "mylocation");
|
||||
saveSettings();
|
||||
|
@ -50,6 +50,25 @@ function setFromGPS() {
|
|||
Bangle.setUI("updown", undefined);
|
||||
}
|
||||
|
||||
function setFromWaypoint() {
|
||||
wpmenu = {
|
||||
'': { 'title': /*LANG*/'Waypoint' },
|
||||
'< Back': ()=>{ showMainMenu(); },
|
||||
};
|
||||
require("waypoints").load().forEach(wp => {
|
||||
if (typeof(wp.lat) === 'number' && typeof(wp.lon) === 'number') {
|
||||
wpmenu[wp.name] = ()=>{
|
||||
s.location = wp.name;
|
||||
s.lat = parseFloat(wp.lat);
|
||||
s.lon = parseFloat(wp.lon);
|
||||
saveSettings();
|
||||
showMainMenu();
|
||||
};
|
||||
}
|
||||
});
|
||||
return E.showMenu(wpmenu);
|
||||
}
|
||||
|
||||
function showMainMenu() {
|
||||
//console.log("showMainMenu");
|
||||
const mainmenu = {
|
||||
|
@ -58,7 +77,13 @@ function showMainMenu() {
|
|||
/*LANG*/'City': {
|
||||
value: 0 | locations.indexOf(s.location),
|
||||
min: 0, max: locations.length - 1,
|
||||
format: v => locations[v],
|
||||
format: v => {
|
||||
if (v === -1) {
|
||||
return s.location;
|
||||
} else {
|
||||
return locations[v];
|
||||
}
|
||||
},
|
||||
onchange: v => {
|
||||
if (locations[v] !== "???") {
|
||||
s.location = locations[v];
|
||||
|
@ -68,7 +93,8 @@ function showMainMenu() {
|
|||
}
|
||||
}
|
||||
},
|
||||
/*LANG*/'Set From GPS': ()=>{ setFromGPS(); }
|
||||
/*LANG*/'Set From GPS': ()=>{ setFromGPS(); },
|
||||
/*LANG*/'Set From Waypoint': ()=>{ setFromWaypoint(); },
|
||||
};
|
||||
return E.showMenu(mainmenu);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue