-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from saiashishanshuman1/main
Weather API #4
- Loading branch information
Showing
5 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# API-directory | ||
Task given to our talented members | ||
# Weather-APP | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel = "stylesheet" href = "./style.css" /> | ||
<title>Weather</title> | ||
</head> | ||
<body> | ||
<div class="location"> | ||
<h1 class="location-timezone">TimeZone </h1> | ||
<p><img id="wicon" src="http://openweathermap.org/img/w/05d.png" alt="Weather Icon" width="100" height="100"></p> | ||
</div> | ||
<div class="temperature"> | ||
<div class="degree-section"> | ||
<h2 class="temperature-degree">34</h2> | ||
<span>°C</span> | ||
</div> | ||
<div class="temperature-description">Its frgging cold</div> | ||
</div> | ||
<script src="index.js"> | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
window.addEventListener('load', () => { | ||
let long; | ||
let lat; | ||
let temperatureDescription = document.querySelector('.temperature-description'); | ||
let temperatureDegree = document.querySelector('.temperature-degree'); | ||
let locationTimezone = document.querySelector('.location-timezone'); | ||
let iconcode | ||
let iconurl | ||
|
||
|
||
|
||
if(navigator.geolocation){ | ||
navigator.geolocation.getCurrentPosition(position =>{ | ||
long = position.coords.longitude; | ||
lat = position.coords.latitude; | ||
|
||
const api =`https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${long}&units=metric&appid=b63b7edcb5598e3d9b7bdfdecf2600c3 | ||
`; | ||
|
||
fetch(api) | ||
.then(response =>{ | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
console.log(data); | ||
const{temp} = data.main; | ||
temperatureDegree.textContent = data.main.temp; | ||
temperatureDescription.textContent = data.weather[0].description; | ||
locationTimezone.textContent = data.name; | ||
iconcode = data.weather[0].icon; | ||
iconurl = "http://openweathermap.org/img/w/" + iconcode + ".png"; | ||
document.getElementById("wicon").src = iconurl | ||
console.log(document.getElementById("wicon").src) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
}); | ||
}); | ||
} | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
body{ | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
flex-direction: column; | ||
align-items: center; | ||
background: radial-gradient(circle, rgba(238,174,202,1) 0%, rgba(148,187,233,1) 100%); | ||
font-family: sans-serif; | ||
color: white; | ||
|
||
} | ||
.location, | ||
.temperature{ | ||
height: 40vh ; | ||
width: 60%; | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
color: black; | ||
} | ||
.temperature{ | ||
flex-direction: column; | ||
} | ||
.degree-section{ | ||
display: flex; | ||
align-items: center; | ||
cursor: pointer; | ||
} | ||
.degree-section span{ | ||
margin: 10px; | ||
font-size: 30px; | ||
} | ||
.degree-section h2{ | ||
font-size: 40px; | ||
} | ||
|