Created
March 7, 2017 21:32
-
-
Save mattborn/53ee390aa62ea440344294a47401ff9a to your computer and use it in GitHub Desktop.
HoppyHour™ Map
This file contains hidden or 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
[ | |
{ | |
"lat": 41.879261, | |
"lng": -87.628403, | |
"name": "Berghoff" | |
} | |
] |
This file contains hidden or 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> | |
<head> | |
<title>HoppyHour™ Map</title> | |
<link rel="stylesheet" href="styles.css"> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | |
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDY8PoPi7QYHf_EnEpyUUjwUpbaB3F9YMk"></script> | |
<script src="scripts.js"></script> | |
</head> | |
<body> | |
<!-- google map goes here --> | |
</body> | |
</html> |
This file contains hidden or 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
var markers = []; | |
var info = []; | |
google.maps.event.addDomListener(window, 'load', function () { | |
var map = new google.maps.Map(document.body, { | |
center: new google.maps.LatLng(41.88, -87.63), | |
zoom: 15, | |
}); | |
$.getJSON('bars.json', function (bars) { | |
bars.forEach(function (bar, index) { | |
markers[index] = new google.maps.Marker({ | |
animation: google.maps.Animation.DROP, | |
icon: 'http://maps.google.com/mapfiles/ms/micons/blue-dot.png', | |
map: map, | |
position: new google.maps.LatLng(bar.lat, bar.lng), | |
}); | |
info[index] = new google.maps.InfoWindow({ | |
content: '<h1>'+ bar.name +'</h1>', | |
}); | |
markers[index].addListener('click', function () { | |
info[index].open(map, markers[index]); | |
}); | |
}); | |
}); | |
}); |
This file contains hidden or 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
body { | |
height: 100vh; | |
margin: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment