-
-
Save Jauny/6d1f5ddd3614ca4065f9 to your computer and use it in GitHub Desktop.
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
<script type="text/javascript"> | |
var directionDisplay; | |
var directionsService = new google.maps.DirectionsService(); | |
var map; | |
function initialize() { | |
directionsDisplay = new google.maps.DirectionsRenderer(); | |
var chicago = new google.maps.LatLng(37.7820, -122.4276); | |
var mapOptions = { | |
zoom:13, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, | |
center: chicago | |
} | |
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); | |
directionsDisplay.setMap(map); | |
} | |
function calcRoute() { | |
var start = "717 California St, San Francisco, CA 94108"; | |
var end = document.getElementById('address').innerHTML; | |
var request = { | |
origin:start, | |
destination:end, | |
travelMode: google.maps.DirectionsTravelMode.DRIVING | |
}; | |
directionsService.route(request, function(response, status) { | |
if (status == google.maps.DirectionsStatus.OK) { | |
directionsDisplay.setDirections(response); | |
} | |
}); | |
} | |
$(window).load(function(){ | |
initialize() | |
calcRoute() | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment