Skip to content

Commit

Permalink
added location coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
jainam03 committed Dec 13, 2023
1 parent 6cb002a commit b093315
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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" />
<link rel="stylesheet" href="./new_style.css" />
<link rel="stylesheet" href="style.css">


<!-- Google tag (gtag.js) -->
Expand Down Expand Up @@ -39,6 +40,7 @@ <h2 style="text-align: center; color: rgba(255,255,255,0.8);">Search for any cit
<main>
<section class="location">
<div class="city"></div>
<div class="coords" ></div>
<div class="date"></div>
</section>
<div class="current">
Expand Down
5 changes: 5 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function getResults(query) {
fetch(`${api.base}weather?q=${query}&units=metric&APPID=${api.key}`)
.then(response => {
if (!response.ok) {
console.log(response)
if (response.status === 404) {
throw new Error("City not found")
} else {
Expand Down Expand Up @@ -57,6 +58,10 @@ function displayResults(weather) {

city.innerText = `${weather.name}, ${weather.sys.country}`

let coords = document.querySelector('.location .coords')

coords.innerText = `Co-ordinates: Lat:${weather.coord.lat}, Lon:${weather.coord.lon}`

let now = new Date();
let date = document.querySelector('.location .date')
date.innerText = dateBuilder(now);
Expand Down

0 comments on commit b093315

Please sign in to comment.