Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function initMap() {
- var directionsService = new google.maps.DirectionsService;
- var directionsDisplay = new google.maps.DirectionsRenderer;
- var map = new google.maps.Map(document.getElementById('map'), {
- zoom: 7,
- center: {lat: 41.85, lng: -87.65}
- });
- directionsDisplay.setMap(map);
- calculateAndDisplayRoute(directionsService, directionsDisplay);
- }
- function calculateAndDisplayRoute(directionsService, directionsDisplay) {
- directionsService.route({
- origin: {lat: 32.493241, lng: -116.928811},
- destination: {lat: 32.494404, lng: -116.851438},
- travelMode: 'DRIVING'
- }, function(response, status) {
- if (status === 'OK') {
- directionsDisplay.setDirections(response);
- console.log(response);
- } else {
- window.alert('Directions request failed due to ' + status);
- }
- });
- }
Add Comment
Please, Sign In to add comment