-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·267 lines (243 loc) · 9.26 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<script src="assets/js/jquery-3.4.1.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAUdx_YdrwbdjQtCLnqK9U2SyIFj5IrgdM&callback=initMap"></script>
</head>
<style>
.table>tbody>tr>td {
vertical-align: middle;
}
#right-panel {
font-family: 'Roboto', 'sans-serif';
line-height: 30px;
padding-left: 10px;
}
#right-panel select,
#right-panel input {
font-size: 15px;
}
#right-panel select {
width: 100%;
}
#right-panel i {
font-size: 12px;
}
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
width: 100%;
height: 60vh;
}
</style>
<body>
<div id="map"></div>
<table class="table text-center">
<thead class="thead thead-dark">
<tr id="theadList">
<th>Route</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
<script defer>
objekWisata = {
0: {
name: 'Objek Wisata Tambalong',
address: 'Objek Wisata Tambalong, Mentirotiku, Rantepao, Kabupaten Toraja Utara, Sulawesi Selatan 91833'
},
1: {
name: 'Batu Mabusa',
address: 'Batu Mabusa, Buntu Barana, Tikala, Kabupaten Toraja Utara, Sulawesi Selatan 91833'
},
2: {
name: 'Objek Wisata Kalimbuang',
address: 'Objek Wisata Kalimbuang, Bori, Sesean, Kabupaten Toraja Utara, Sulawesi Selatan 91853'
},
3: {
name: 'To` Tombi',
address: 'To Tombi, Lolai, Kapala Pitu, Kabupaten Toraja Utara, Sulawesi Selatan 91854'
},
4: {
name: 'Lombok Parinding',
address: 'Lombok Parinding, Butu Lobo, Sesean, Kabupaten Toraja Utara, Sulawesi Selatan 91853'
},
5: {
name: 'Lo` Ko` Mata',
address: 'Lo Ko Mata, Sesean Matallo, Sesean Suloara, Kabupaten Toraja Utara, Sulawesi Selatan 91833'
},
6: {
name: 'Objek Wisata Batu Kianak',
address: 'Objek Wisata Batu Kianak, Sa do, Jl. Poros Sa dan Pebulian, Saalimbong adan, Sa dan, Kabupaten Toraja Utara, Sulawesi Selatan 91853'
},
7: {
name: 'Buntu Pune',
address: 'Buntu Pune, Ba tan, Kesu, Kabupaten Toraja Utara, Sulawesi Selatan 91834'
},
8: {
name: 'Ke` Te` Kesu`',
address: 'Ke Te Kesu, Pantanakan Lolo, Kesu, Kabupaten Toraja Utara, Sulawesi Selatan 91834'
},
9: {
name: 'Objek Wisata Palawa`',
address: 'Objek Wisata Palawa, Palawa, Sesean, Kabupaten Toraja Utara, Sulawesi Selatan 91853'
},
10: {
name: 'Museum Ne` gandeng',
address: 'Museum Ne gandeng, Museum Ne gandeng, Malakiri, North Toraja Regency, South Sulawesi'
},
11: {
name: 'Pana`',
address: 'Pana Oldest Child Grave Rock Cemetery, Suloara, Sesean Suloara, Kabupaten Toraja Utara, Sulawesi Selatan 91853'
},
12: {
name: 'Kawasan Wisata Tinimbayo',
address: 'Buntu, Lempo, Sesean Suloara, Kabupaten Toraja Utara, Sulawesi Selatan'
},
13: {
name: 'Sarambu Sikore',
address: 'Sarambu Sikore, Awan, Awan Rante Karua, Kabupaten Toraja Utara, Sulawesi Selatan 91856'
},
14: {
name: 'Londa',
address: 'Londa, Lembang Sangbua, Kesu, Tadongkon, Kesu, Kabupaten Toraja Utara, Sulawesi Selatan 91852'
},
15: {
name: 'Rante Karassik',
address: 'Rante Karassik, Karassik, Rantepao, Kabupaten Toraja Utara, Sulawesi Selatan 91834'
},
16: {
name: 'Terminal Makale',
address: 'Terminal Makale, Kamali Pentalluan, Makale, Tana Toraja Regency, South Sulawesi 91811'
},
}
var vehicle = {}
var waypts = [];
function initMap() {
$.get("https://azharizkita.pythonanywhere.com/", function (params) {
var VRPSA = params.split('-')
for (let i = 0; i < VRPSA.length; i++) {
postRoute = []
postTimeMin = []
postTimeMax = []
var tempVRPSA = VRPSA[i]
tempVRPSA = tempVRPSA.split('|')
if (tempVRPSA[0] != '' && tempVRPSA[0] != null) {
routeTemp = tempVRPSA[1].split(',')
for (let index = 0; index < routeTemp.length; index++) {
if (routeTemp[index] != '' && routeTemp[index] != null && routeTemp[index] != Object.keys(objekWisata).length - 1) {
postRoute.push(parseInt(routeTemp[index]))
}
}
timeMinTemp = tempVRPSA[2].split(',')
for (let index = 0; index < timeMinTemp.length; index++) {
if (timeMinTemp[index] != '' && timeMinTemp[index] != null && routeTemp[index] != Object.keys(objekWisata).length - 1) {
postTimeMin.push(parseInt(timeMinTemp[index]))
}
}
timeMaxTemp = tempVRPSA[3].split(',')
for (let index = 0; index < timeMaxTemp.length; index++) {
if (timeMaxTemp[index] != '' && timeMaxTemp[index] != null && routeTemp[index] != Object.keys(objekWisata).length - 1) {
postTimeMax.push(parseInt(timeMaxTemp[index]))
}
}
if (tempVRPSA[4] != 7) {
vehicle[tempVRPSA[0]] = {
'route': postRoute,
'timeMin': postTimeMin,
'timeMax': postTimeMax,
'travelTime': tempVRPSA[4]
}
}
}
}
var directionsService = new google.maps.DirectionsService;
var directionsRenderer = new google.maps.DirectionsRenderer;
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 6,
center: new google.maps.LatLng(-1.9638452, 121.0589356)
});
directionsRenderer.setMap(map);
if (Object.keys(vehicle).length == 1) {
if (vehicle[parseInt(Object.keys(vehicle))].travelTime != 0) {
i = 1;
routeName = '<hr><li><strong>'+objekWisata[16].name+'</strong></li><hr>'
for (let j = 0; j < vehicle[parseInt(Object.keys(vehicle))].route.length; j++) {
routeName += '<li class="">'+objekWisata[vehicle[parseInt(Object.keys(vehicle))].route[j]].name + '</li><hr>'
}
routeName += '<hr><li><strong>'+objekWisata[16].name+'</strong></li><hr>'
$('table').find('tbody').append("<tr><td><ul style='width:100%;list-style-type:none;' class='btn btn-outline-danger' id='vehicleBtn" + parseInt(Object.keys(vehicle)) + "' data-vid='" + parseInt(Object.keys(vehicle)) + "'>" + routeName + "</ul></td></tr>");
document.getElementById('vehicleBtn' + parseInt(Object.keys(vehicle))).addEventListener('click', function (event) {
vehicleId = document.getElementById('vehicleBtn' + parseInt(Object.keys(vehicle))).getAttribute('data-vid')
calculateAndDisplayRoute(directionsService, directionsRenderer, vehicleId);
});
for (var j = 0; j < vehicle[parseInt(Object.keys(vehicle))].route.length; j++) {
if (vehicle[parseInt(Object.keys(vehicle))].route[j] != objekWisata.length) {
waypts.push({
location: objekWisata[vehicle[parseInt(Object.keys(vehicle))].route[j]].address,
stopover: true
});
}
}
}
} else {
var row = document.getElementById("theadList");
var x = row.insertCell(0);
x.innerHTML = "Route id";
for (let i = 0; i < Object.keys(vehicle).length; i++) {
if (vehicle[i].travelTime != 0) {
num = 1;
routeName = ''
for (let j = 0; j < vehicle[i].route.length; j++) {
routeName += objekWisata[vehicle[i].route[j]].name + ', '
}
$('table').find('tbody').append("<tr><td>" + num + "</td><td>" + routeName + "</td><td><input id='vehicleBtn" + i + "' type='button' class='btn btn-success' value='Show' data-vid='" + i + "'></td></tr>");
document.getElementById('vehicleBtn' + i).addEventListener('click', function (event) {
vehicleId = document.getElementById('vehicleBtn' + i).getAttribute('data-vid')
calculateAndDisplayRoute(directionsService, directionsRenderer, vehicleId);
});
num++
for (var j = 0; j < vehicle[vehicleId].route.length; j++) {
if (vehicle[vehicleId].route[j] != objekWisata.length) {
waypts.push({
location: objekWisata[vehicle[vehicleId].route[j]].address,
stopover: true
});
}
}
}
}
}
function calculateAndDisplayRoute(directionsService, directionsRenderer, vehicleId) {
directionsService.route({
origin: objekWisata[Object.keys(objekWisata).length - 1].address,
destination: objekWisata[Object.keys(objekWisata).length - 1].address,
waypoints: waypts,
optimizeWaypoints: true,
travelMode: 'WALKING'
}, function (response, status) {
if (status === 'OK') {
directionsRenderer.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
});
}
</script>
</html>