commit
db91bd94b5
@ -24,7 +24,21 @@ const key = `${CONFIG.weatherKey}`;
|
||||
setPosition();
|
||||
|
||||
function setPosition(position) {
|
||||
getWeather(CONFIG.weatherLatitude, CONFIG.weatherLongitude);
|
||||
if (!CONFIG.trackLocation || !navigator.geolocation) {
|
||||
if (CONFIG.trackLocation) {
|
||||
console.error('Geolocation not available');
|
||||
}
|
||||
getWeather(CONFIG.defaultLatitude, CONFIG.defaultLongitude);
|
||||
return;
|
||||
}
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(pos) => {
|
||||
getWeather(pos.coords.latitude.toFixed(3), pos.coords.longitude.toFixed(3));
|
||||
}, (err) => {
|
||||
console.error(err);
|
||||
getWeather(CONFIG.defaultLatitude, CONFIG.defaultLongitude);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Get the Weather data
|
||||
|
@ -26,8 +26,9 @@ const CONFIG = {
|
||||
weatherKey: 'InsertYourAPIKeyHere123456',
|
||||
weatherIcons: 'OneDark', // 'Nord', 'Dark', 'White'
|
||||
weatherUnit: 'C',
|
||||
weatherLatitude: '37.774929',
|
||||
weatherLongitude: '-122.419418',
|
||||
trackLocation: false, // If false or an error occurs, the app will use the lat/lon below
|
||||
defaultLatitude: '37.775',
|
||||
defaultLongitude: '-122.419',
|
||||
|
||||
// ┌─┐┌─┐┬─┐┌┬┐┌─┐
|
||||
// │ ├─┤├┬┘ ││└─┐
|
||||
|
Loading…
x
Reference in New Issue
Block a user