Created
November 20, 2018 20:28
-
-
Save Aurea-Li/d9a42d33af790734d5ea0029062387aa to your computer and use it in GitHub Desktop.
Seven Wonders
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
<!DOCTYPE html> | |
<html lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Seven Wonders</title> | |
<script | |
src="https://code.jquery.com/jquery-3.3.1.js"></script> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<script type="text/javascript" src="index.js"></script> | |
</head> | |
<body> | |
<h1> Seven Wonders of the World </h1> | |
<section class='status-message'></section> | |
<section> | |
<ul> | |
</ul> | |
</section> | |
</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
const sevenWonders = [ | |
"Great Pyramid of Giza", | |
"Hanging Gardens of Babylon", | |
"Colossus of Rhodes", | |
"Pharos of Alexandria", | |
"Statue of Zeus at Olympia", | |
"Temple of Artemis", | |
"Mausoleum at Halicarnassus" | |
]; | |
const reportStatus = (message) => { | |
$('.status-message').html(message); | |
}; | |
const getCoordinates = (location) => { | |
const address = location.split(' ').join('+'); | |
const URL = `https://maps.googleapis.com/maps/api/geocode/json?address=${address}&bounds=27.057438, 14.611095|40.948759, 49.189896&key=AIzaSyATN28EAkT5djmWAw6dREBAV4vgt2c0vDw`; | |
axios.get(URL) | |
.then((response) => { | |
const l = $('ul'); | |
const coordinates = response.data.results[0].geometry.location; | |
l.append(`<li> ${location} : ${coordinates.lat}, ${coordinates.lng}</li>`); | |
}) | |
.catch((error) => { | |
console.log(error); | |
}); | |
}; | |
$(document).ready(() => { | |
reportStatus('Loading coordinates ...'); | |
sevenWonders.forEach( (wonder) => { | |
getCoordinates(wonder); | |
}); | |
reportStatus('Successfully loaded seven wonders coordinates!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment