Created
March 19, 2016 22:51
-
-
Save valentina-s/14a683caa87c7df77396 to your computer and use it in GitHub Desktop.
JavaScript Snippet displaying a map and directions of a location in Seattle (based on the name)
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> | |
<body> | |
<p>Discovery Park</p> | |
<button onclick="showMap('Discovery Park')">View Map</button> | |
<button onclick="showDirections('Discovery Park')">View Directions</button> | |
<script> | |
// Function showing the map | |
function showMap(name) { | |
new_name = name.split(" ").join("+") | |
address = "https://www.google.com/maps/place/" | |
googleMapsAddress = address.concat(new_name).concat(",seattle,wa") | |
window.open(googleMapsAddress); | |
} | |
//Function showing the directions | |
function showDirections(name) { | |
new_name = name.split(" ").join("+") | |
address = "https://www.google.com/maps/dir/Current+Location/" | |
googleMapsAddress = address.concat(new_name).concat(",seattle,wa") | |
window.open(googleMapsAddress); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment