//AIzaSyAPYatPrCcmNcVdAO_MF0YhO3c1mgdLvuQ var app = angular.module('batmanDelivers', []); /////////// //Controller /////////// app.controller('myCtrl', function($scope, $http) { var map = null; var markers = []; var route = null; var map = null; var marker = null; var markers = []; var myLatLng = { lat: 0, lng: 0 }; var directionsService; var directionsDisplay; var end; var marked; $scope.show = false; initMap(); function displayRoute() { if (start && end != undefined) { calculateAndDisplayRoute(start, end); } else { console.log("need both start and ending destinations"); } } function draw(sel){ if (marked) { deleteMarkers(); drawMarker(); end = sel.description; } else { debugger; drawMarker(); marked = true; start = sel.description; } } function calculateAndDisplayRoute(start, end) { directionsService.route({ origin: start, destination: end, travelMode: 'DRIVING' }, function(response, status) { if (status === 'OK') { directionsDisplay.setDirections(response); } else { window.alert('Directions request failed due to ' + status); } }); } function clearMarkers() { markers = []; } function setMapOnAll(map) { for (var i = 0; i < markers.length; i++) { markers[i].setMap(map); } } function drawMarker() { var marker = new google.maps.Marker({ position: myLatLng, map: map, }); markers.push(marker); } function initMap() { directionsService = new google.maps.DirectionsService; directionsDisplay = new google.maps.DirectionsRenderer; map = new google.maps.Map(document.getElementById('map-div'), { center: { lat: 51.491903, lng: -0.024640 }, zoom: 14, mapTypeControl: false, styles: [{ "featureType": "all", "elementType": "labels.text.fill", "stylers": [{ "saturation": 36 }, { "color": "#000000" }, { "lightness": 40 } ] }, { "featureType": "all", "elementType": "labels.text.stroke", "stylers": [{ "visibility": "on" }, { "color": "#000000" }, { "lightness": 16 } ] }, { "featureType": "all", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "featureType": "administrative", "elementType": "geometry.fill", "stylers": [{ "color": "#000000" }, { "lightness": 20 } ] }, { "featureType": "administrative", "elementType": "geometry.stroke", "stylers": [{ "color": "#000000" }, { "lightness": 17 }, { "weight": 1.2 } ] }, { "featureType": "landscape", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 20 } ] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 21 } ] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{ "color": "#000000" }, { "lightness": 17 } ] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#000000" }, { "lightness": 29 }, { "weight": 0.2 } ] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 18 } ] }, { "featureType": "road.local", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 16 } ] }, { "featureType": "transit", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 19 } ] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 17 } ] } ] }); directionsDisplay.setMap(map); } });