Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Simple Map</title>
- <meta name="viewport" content="initial-scale=1.0">
- <meta charset="utf-8">
- <style>
- /* Always set the map height explicitly to define the size of the div
- * element that contains the map. */
- #map {
- height: 100%;
- }
- /* Optional: Makes the sample page fill the window. */
- html, body {
- height: 100%;
- margin: 0;
- padding: 0;
- }
- </style>
- </head>
- <body>
- <div id="map"></div>
- <script>
- function initMap() {
- var directionsService = new google.maps.DirectionsService();
- var directionsDisplay = new google.maps.DirectionsRenderer();
- var mark = [{lat: 65.5981443, lng: 37.7177781},{lat: 50.5981443, lng: 37.7177781}]
- var map = new google.maps.Map(document.getElementById('map'), {
- zoom: 3,
- center: mark[0]
- });
- // for(let i of mark){
- // new google.maps.Marker({
- // position: {lat: i.lat, lng: i.lng},
- // map: map
- // });
- // }
- directionsDisplay.setMap(map);
- calcRoute(directionsDisplay, directionsService);
- }
- function calcRoute(directionsDisplay, directionsService) {
- var request = {
- origin: new google.maps.LatLng(35.5981443, 37.7177781),
- destination: new google.maps.LatLng(37.5981443, 55.7177781),
- waypoints: [
- {
- location: new google.maps.LatLng(36.5981443, 37.7177781),
- stopover: true
- },
- {
- location: new google.maps.LatLng(38.5981443, 37.7177781),
- stopover: true
- }
- ],
- provideRouteAlternatives: false,
- travelMode: 'DRIVING',
- drivingOptions: {
- departureTime: new Date()
- },
- unitSystem: google.maps.UnitSystem.IMPERIAL
- }
- directionsService.route(request, function(result, status) {
- console.log(result, status);
- if (status == 'OK') {
- directionsDisplay.setDirections(result);
- }
- });
- }
- </script>
- <script src="https://maps.googleapis.com/maps/api/js?key=&callback=initMap"
- async defer></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement