Update mylocation.app.js

two cities added
pull/1430/head
Hilmar Strauch 2022-02-12 13:21:22 +01:00 committed by GitHub
parent 0cbdc5210b
commit a4b6bb26b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 11 deletions

View File

@ -9,32 +9,32 @@ let s = {
'lat': 51.5072,
'lon': 0.1276,
'location': "London"
}
};
function loadSettings() {
settings = require('Storage').readJSON(SETTINGS_FILE, 1) || s;
}
function save() {
settings = s
require('Storage').write(SETTINGS_FILE, settings)
settings = s;
require('Storage').write(SETTINGS_FILE, settings);
}
const locations = ["London", "Newcastle", "Edinburgh", "Paris", "New York", "Tokyo","???"];
const lats = [51.5072 ,54.9783 ,55.9533 ,48.8566 ,40.7128 ,35.6762, 0.0];
const lons = [-0.1276 ,-1.6178 ,-3.1883 ,2.3522 , -74.0060 ,139.6503, 0.0];
const locations = ["London" ,"Newcastle","Edinburgh", "Paris" , "New York" , "Tokyo" , "Frankfurt", "Auckland", "???"];
const lats = [ 51.5072 , 54.9783 , 55.9533 , 48.8566 , 40.7128 , 35.6762 , 50.1236 , -36.9 , 0.0 ];
const lons = [ -0.1276 , -1.6178 , -3.1883 , 2.3522 , -74.0060 , 139.6503 , 8.6553 , 174.7832 , 0.0 ];
function setFromGPS() {
Bangle.on('GPS', (gps) => {
//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': '???' };
Bangle.buzz(1500); // buzz on first position
Bangle.setGPSPower(0);
save();
Bangle.setUI("updown", ()=>{ load() });
Bangle.setUI("updown", ()=>{ load(); });
E.showPrompt("Location has been saved from the GPS fix",{
title:"Location Saved",
buttons : {"OK":1}
@ -49,13 +49,13 @@ function setFromGPS() {
}
function showMainMenu() {
console.log("showMainMenu");
// console.log("showMainMenu");
const mainmenu = {
'': { 'title': 'My Location' },
'<Back': ()=>{ load(); },
'City': {
value: 0 | locations.indexOf(s.location),
min: 0, max: 6,
min: 0, max: locations.length - 1,
format: v => locations[v],
onchange: v => {
if (v != 6) {
@ -67,7 +67,7 @@ function showMainMenu() {
}
},
'Set From GPS': ()=>{ setFromGPS(); }
}
};
return E.showMenu(mainmenu);
}