Blame view

src/js/app.js 7.16 KB
856e1d58   Sean Wills   Search menu
1
//AIzaSyAPYatPrCcmNcVdAO_MF0YhO3c1mgdLvuQ
b2145b07   Tarpit Grover   WIP
2
var app = angular.module('batmanDelivers', ['ngSanitize', 'ui.select']);
3ef35c23   Sean Wills   Commented feature...
3
4
5
6

///////////
//Controller
///////////
856e1d58   Sean Wills   Search menu
7
8

app.controller('myCtrl', function($scope, $http) {
01ae2e35   Sean Wills   Falied smooth mov...
9

3ef35c23   Sean Wills   Commented feature...
10
    var map = null;
93483f6d   Sean Wills   Settings Working,...
11
    var markers = [];
3ef35c23   Sean Wills   Commented feature...
12
13
14
15
16
17
18
19
20
21
    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;
93483f6d   Sean Wills   Settings Working,...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

    initMap();

    $scope.stops = [{
        "Description": "Start typing to search...",
    }, {
        "Description": "Start typing to search...",
    }]


    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'
3ef35c23   Sean Wills   Commented feature...
58
59
60
61
62
63
64
        }, function(response, status) {
            if (status === 'OK') {
                directionsDisplay.setDirections(response);
            } else {
                window.alert('Directions request failed due to ' + status);
            }
        });
de63be91   Sean Wills   No settings
65
    }
3ef35c23   Sean Wills   Commented feature...
66
67
68
69
70

    function clearMarkers() {
        markers = [];
    }

484036e0   Tarpit Grover   WIP
71
    function setMapOnAll(map) {
b2145b07   Tarpit Grover   WIP
72
        for (var i = 0; i < markers.length; i++) {
3ef35c23   Sean Wills   Commented feature...
73
74
            markers[i].setMap(map);
        }
01ae2e35   Sean Wills   Falied smooth mov...
75
76
    }

01ae2e35   Sean Wills   Falied smooth mov...
77
    function drawMarker() {
856e1d58   Sean Wills   Search menu
78
        var marker = new google.maps.Marker({
3ef35c23   Sean Wills   Commented feature...
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
            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": [{
856e1d58   Sean Wills   Search menu
96
                            "saturation": 36
856e1d58   Sean Wills   Search menu
97
                        },
ec938bf0   Tarpit Grover   first commit
98
                        {
3ef35c23   Sean Wills   Commented feature...
99
100
101
102
103
104
105
106
107
                            "color": "#000000"
                        },
                        {
                            "lightness": 40
                        }
                    ]
                },
                {
                    "featureType": "all",
93483f6d   Sean Wills   Settings Working,...
108
109
110
111
112
113
114
                    "elementType": "labels.text.stroke",
                    "stylers": [{
                            "visibility": "on"
                        },
                        {
                            "color": "#000000"
                        },
3ef35c23   Sean Wills   Commented feature...
115
                        {
93483f6d   Sean Wills   Settings Working,...
116
117
118
119
120
                            "lightness": 16
                        }
                    ]
                },
                {
3ef35c23   Sean Wills   Commented feature...
121
122
123
124
                    "featureType": "all",
                    "elementType": "labels.icon",
                    "stylers": [{
                        "visibility": "off"
93483f6d   Sean Wills   Settings Working,...
125
126
127
                    }]
                },
                {
3ef35c23   Sean Wills   Commented feature...
128
129
                    "featureType": "administrative",
                    "elementType": "geometry.fill",
ec938bf0   Tarpit Grover   first commit
130
                    "stylers": [{
ec938bf0   Tarpit Grover   first commit
131
                            "color": "#000000"
3ef35c23   Sean Wills   Commented feature...
132
                        },
01ae2e35   Sean Wills   Falied smooth mov...
133
134
135
136
137
                        {
                            "lightness": 20
                        }
                    ]
                },
b2145b07   Tarpit Grover   WIP
138
                {
ec938bf0   Tarpit Grover   first commit
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
                    "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);
    }
});
b2145b07   Tarpit Grover   WIP

ec938bf0   Tarpit Grover   first commit

a0fba7c8   David Beech   david

ec938bf0   Tarpit Grover   first commit

01ae2e35   Sean Wills   Falied smooth mov...

01ae2e35   Sean Wills   Falied smooth mov...

b2145b07   Tarpit Grover   WIP

01ae2e35   Sean Wills   Falied smooth mov...

b2145b07   Tarpit Grover   WIP

01ae2e35   Sean Wills   Falied smooth mov...

856e1d58   Sean Wills   Search menu

3ef35c23   Sean Wills   Commented feature...

93483f6d   Sean Wills   Settings Working,...

3ef35c23   Sean Wills   Commented feature...

01ae2e35   Sean Wills   Falied smooth mov...

26ced867   Sean Wills   New commit

5b416886   Sean Wills   Move and rotate

01ae2e35   Sean Wills   Falied smooth mov...

b2145b07   Tarpit Grover   WIP

01ae2e35   Sean Wills   Falied smooth mov...

5b416886   Sean Wills   Move and rotate

01ae2e35   Sean Wills   Falied smooth mov...

856e1d58   Sean Wills   Search menu

5b416886   Sean Wills   Move and rotate

856e1d58   Sean Wills   Search menu

26ced867   Sean Wills   New commit

856e1d58   Sean Wills   Search menu

3ef35c23   Sean Wills   Commented feature...

b2145b07   Tarpit Grover   WIP

93483f6d   Sean Wills   Settings Working,...

3ef35c23   Sean Wills   Commented feature...

856e1d58   Sean Wills   Search menu

3ef35c23   Sean Wills   Commented feature...

856e1d58   Sean Wills   Search menu

3ef35c23   Sean Wills   Commented feature...

856e1d58   Sean Wills   Search menu

3ef35c23   Sean Wills   Commented feature...

856e1d58   Sean Wills   Search menu

3ef35c23   Sean Wills   Commented feature...

856e1d58   Sean Wills   Search menu

3ef35c23   Sean Wills   Commented feature...

93483f6d   Sean Wills   Settings Working,...

3ef35c23   Sean Wills   Commented feature...

93483f6d   Sean Wills   Settings Working,...

856e1d58   Sean Wills   Search menu

b2145b07   Tarpit Grover   WIP

1131cb0d   Sean Wills   First commit

b2145b07   Tarpit Grover   WIP

1131cb0d   Sean Wills   First commit

3ef35c23   Sean Wills   Commented feature...

93483f6d   Sean Wills   Settings Working,...

3ef35c23   Sean Wills   Commented feature...

93483f6d   Sean Wills   Settings Working,...

3ef35c23   Sean Wills   Commented feature...

93483f6d   Sean Wills   Settings Working,...

3ef35c23   Sean Wills   Commented feature...

93483f6d   Sean Wills   Settings Working,...

3ef35c23   Sean Wills   Commented feature...

856e1d58   Sean Wills   Search menu