Guest User

Untitled

a guest
Jun 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. function initMap() {
  2. var directionsService = new google.maps.DirectionsService;
  3. var directionsDisplay = new google.maps.DirectionsRenderer;
  4. var map = new google.maps.Map(document.getElementById('map'), {
  5. zoom: 7,
  6. center: {lat: 41.85, lng: -87.65}
  7. });
  8. directionsDisplay.setMap(map);
  9.  
  10.  
  11. calculateAndDisplayRoute(directionsService, directionsDisplay);
  12.  
  13. }
  14. function calculateAndDisplayRoute(directionsService, directionsDisplay) {
  15. directionsService.route({
  16. origin: {lat: 32.493241, lng: -116.928811},
  17. destination: {lat: 32.494404, lng: -116.851438},
  18. travelMode: 'DRIVING'
  19. }, function(response, status) {
  20. if (status === 'OK') {
  21. directionsDisplay.setDirections(response);
  22. console.log(response);
  23. } else {
  24. window.alert('Directions request failed due to ' + status);
  25. }
  26. });
  27. }
Add Comment
Please, Sign In to add comment