lan and long automaticly
This commit is contained in:
parent
7adca9f0be
commit
c3fb9da5af
@ -24,12 +24,14 @@ const key = `${CONFIG.weatherKey}`;
|
|||||||
setPosition();
|
setPosition();
|
||||||
|
|
||||||
function setPosition(position) {
|
function setPosition(position) {
|
||||||
getWeather(CONFIG.weatherLatitude, CONFIG.weatherLongitude);
|
getWeather();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Weather data
|
// Get the Weather data
|
||||||
function getWeather(latitude, longitude) {
|
function getWeather() {
|
||||||
let api = `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=${key}`;
|
if(navigator.geolocation) {
|
||||||
|
navigator.geolocation.getCurrentPosition(function(a) {
|
||||||
|
let api = `https://api.openweathermap.org/data/2.5/weather?lat=${a.coords["latitude"]}&lon=${a.coords["longitude"]}&appid=${key}`;
|
||||||
|
|
||||||
console.log(api);
|
console.log(api);
|
||||||
|
|
||||||
@ -48,6 +50,8 @@ function getWeather(latitude, longitude) {
|
|||||||
.then(function () {
|
.then(function () {
|
||||||
displayWeather();
|
displayWeather();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display Weather info
|
// Display Weather info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user