Skip to content

Instantly share code, notes, and snippets.

@juliaogris
Forked from mikeurbach/example.html
Last active August 29, 2015 14:28
Show Gist options
  • Save juliaogris/2d3b96ac3e981c8c3051 to your computer and use it in GitHub Desktop.
Save juliaogris/2d3b96ac3e981c8c3051 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?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