Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Simple Map</title>
  5. <meta name="viewport" content="initial-scale=1.0">
  6. <meta charset="utf-8">
  7. <style>
  8. /* Always set the map height explicitly to define the size of the div
  9. * element that contains the map. */
  10. #map {
  11. height: 100%;
  12. }
  13. /* Optional: Makes the sample page fill the window. */
  14. html, body {
  15. height: 100%;
  16. margin: 0;
  17. padding: 0;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <div id="map"></div>
  23. <script>
  24. function initMap() {
  25. var directionsService = new google.maps.DirectionsService();
  26. var directionsDisplay = new google.maps.DirectionsRenderer();
  27. var mark = [{lat: 65.5981443, lng: 37.7177781},{lat: 50.5981443, lng: 37.7177781}]
  28. var map = new google.maps.Map(document.getElementById('map'), {
  29. zoom: 3,
  30. center: mark[0]
  31. });
  32. // for(let i of mark){
  33. // new google.maps.Marker({
  34. // position: {lat: i.lat, lng: i.lng},
  35. // map: map
  36. // });
  37. // }
  38. directionsDisplay.setMap(map);
  39. calcRoute(directionsDisplay, directionsService);
  40. }
  41.  
  42. function calcRoute(directionsDisplay, directionsService) {
  43. var request = {
  44. origin: new google.maps.LatLng(35.5981443, 37.7177781),
  45. destination: new google.maps.LatLng(37.5981443, 55.7177781),
  46. waypoints: [
  47. {
  48. location: new google.maps.LatLng(36.5981443, 37.7177781),
  49. stopover: true
  50. },
  51. {
  52. location: new google.maps.LatLng(38.5981443, 37.7177781),
  53. stopover: true
  54. }
  55. ],
  56. provideRouteAlternatives: false,
  57. travelMode: 'DRIVING',
  58. drivingOptions: {
  59. departureTime: new Date()
  60. },
  61. unitSystem: google.maps.UnitSystem.IMPERIAL
  62. }
  63. directionsService.route(request, function(result, status) {
  64. console.log(result, status);
  65. if (status == 'OK') {
  66. directionsDisplay.setDirections(result);
  67. }
  68. });
  69. }
  70. </script>
  71. <script src="https://maps.googleapis.com/maps/api/js?key=&callback=initMap"
  72. async defer></script>
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement