Skip to content

Instantly share code, notes, and snippets.

@MichaelCPell
Last active June 23, 2016 21:17
Show Gist options
  • Save MichaelCPell/0a7d77de42233a8888ee9feee0a2de27 to your computer and use it in GitHub Desktop.
Save MichaelCPell/0a7d77de42233a8888ee9feee0a2de27 to your computer and use it in GitHub Desktop.
directions_renderer.js
var renderers = [];
GoogleMapsApi.displayRoute = function(origin, place, map){
options = {
preserveViewport: true,
markerOptions: {
strokeColor: "black"
}
};
var directionsDisplay = new google.maps.DirectionsRenderer(options);
renderers.push({renderer: directionsDisplay, id: place.formatted_address});
directionsDisplay.setMap(map);
directionsService.route({
origin: origin.formatted_address,
destination: place.formatted_address,
travelMode: google.maps.TravelMode.DRIVING
}, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
console.log('Directions request failed due to ' + status);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment