Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Driving Directions / v2
<p>Get driving directions from your neighborhood:</p>
<a href="#" class="driving-directions" data-origin="Wattle Glen, Diamond Creek, Victoria 3089">From Wattle Glen</a>
<a href="#" class="driving-directions" data-origin="Watsonia, Diamond Creek, Victoria 3089">From Watsonia</a>
<a href="#" class="driving-directions" data-origin="St Helena, Diamond Creek, Victoria 3089">From St Helena</a>
<a href="#" class="driving-directions" data-origin="Plenty, Diamond Creek, Victoria 3089">From Plenty</a>
<a href="#" class="driving-directions" data-origin="Montmorency, Diamond Creek, Victoria 3089">From Montmorency</a>
<a href="#" class="driving-directions" data-origin="Hurstbridge, Diamond Creek, Victoria 3089">From Hurstbridge</a>
<a href="#" class="driving-directions" data-origin="Bundoora, Diamond Creek, Victoria 3089">From Bundoora</a>
<a href="#" class="driving-directions" data-origin="Doreen, Diamond Creek, Victoria 3089">From Doreen</a>
<a href="#" class="driving-directions" data-origin="Eltham, Diamond Creek, Victoria 3089">From Eltham</a>
<a href="#" class="driving-directions" data-origin="Greensborough, Diamond Creek, Victoria 3089">From Greensborough</a>
<script type="text/javascript">
$(document).ready(function() {
$('a.driving-directions').on('click', function(e) {
e.preventDefault();
var neighborhood = $(this).data('origin');
$("#map").gmap3({
getroute: {
options: {
origin: neighborhood,
destination: '10/331 Diamond Creek Road Diamond Creek VIC 3089',
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results) {
if ( ! results)
return;
$(this).gmap3({
map: {
options: {
zoom: 9,
center: [-37.677511, 145.127850]
}
}
});
}
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment