Skip to content

Instantly share code, notes, and snippets.

@Jauny
Created November 29, 2012 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jauny/6d1f5ddd3614ca4065f9 to your computer and use it in GitHub Desktop.
Save Jauny/6d1f5ddd3614ca4065f9 to your computer and use it in GitHub Desktop.
<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