Last active
June 23, 2016 21:17
-
-
Save MichaelCPell/0a7d77de42233a8888ee9feee0a2de27 to your computer and use it in GitHub Desktop.
directions_renderer.js
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
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