Skip to content

Instantly share code, notes, and snippets.

@mikeurbach
Last active August 29, 2015 14:27
Show Gist options
  • Save mikeurbach/4d258c44db2d55c48fbf to your computer and use it in GitHub Desktop.
Save mikeurbach/4d258c44db2d55c48fbf to your computer and use it in GitHub Desktop.
Simple Google Map
<!DOCTYPE html>
<html>
<body>
<div id="map" style="position: absolute; width: 100%; height: 100%"></div>
<script type="text/javascript">
function init(){
var map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(37, -95),
zoom: 5
});
var directionsService = new google.maps.DirectionsService;
var directionsRenderer = new google.maps.DirectionsRenderer;
directionsRenderer.setMap(map);
directionsService.route({
origin: 'San Diego, CA',
destination: 'Hanover, NH',
travelMode: google.maps.TravelMode.DRIVING
}, function(directions){
directionsRenderer.setDirections(directions);
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD5vI3EPMXRt7K4aOx2eDEhTQDPrRjHmjw&callback=init" defer async></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment