-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapsloc.html
326 lines (265 loc) · 28.1 KB
/
mapsloc.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<!DOCTYPE html>
<html>
<head>
<title>Place Autocomplete</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<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;
}
.controls {
margin-top: 10px;
border: 1px solid transparent;
border-radius: 2px 0 0 2px;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: 32px;
outline: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#origin-input,
#destination-input {
background-color: #fff;
font-family: Roboto;
font-size: 15px;
font-weight: 300;
margin-left: 12px;
padding: 0 11px 0 13px;
text-overflow: ellipsis;
width: 200px;
}
#origin-input:focus,
#destination-input:focus {
border-color: #4d90fe;
}
#mode-selector {
color: #fff;
background-color: #4d90fe;
margin-left: 12px;
padding: 5px 11px 0px 11px;
}
#mode-selector label {
font-family: Roboto;
font-size: 13px;
font-weight: 300;
}
</style>
</head>
<body>
<input id="origin-input" class="controls" type="text"
placeholder="Enter an origin location">
<input id="destination-input" class="controls" type="text"
placeholder="Enter a destination location">
<div id="mode-selector" class="controls">
<input type="radio" name="type" id="changemode-walking" checked="checked">
<label for="changemode-walking">Walking</label>
<input type="radio" name="type" id="changemode-transit">
<label for="changemode-transit">Transit</label>
<input type="radio" name="type" id="changemode-driving">
<label for="changemode-driving">Driving</label>
</div>
<div id="map" ></div>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCOTnscunfQf7vssoZiv3KTTzHXfUdaS7M&libraries=places"
></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var getcrimequotient= [
{'lati': 77.249200000000002, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.536300000000001}, {'lati': 77.085999999999999, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.6127}, {'lati': 77.2042, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.529900000000001}, {'lati': 77.236099999999993, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.643599999999999}, {'lati': 77.193700000000007, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.7026}, {'lati': 77.293700000000001, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.653400000000001}, {'lati': 77.226200000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.666399999999999}, {'lati': 77.265299999999996, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.5307}, {'lati': 77.066199999999995, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.609100000000002}, {'lati': 77.267600000000002, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.5623}, {'lati': 77.306200000000004, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.523}, {'lati': 77.224199999999996, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.7072}, {'lati': 77.003600000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.7258}, {'lati': 77.1738, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.66}, {'lati': 77.086399999999998, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.5914}, {'lati': 77.127600000000001, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.7179}, {'lati': 77.179000000000002, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.570499999999999}, {'lati': 77.115899999999996, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.702400000000001}, {'lati': 77.132800000000003, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.674399999999999}, {'lati': 77.015600000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.6037}, {'lati': 77.197400000000002, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.736599999999999}, {'lati': 77.233599999999996, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.652799999999999}, {'lati': 77.175299999999993, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.709800000000001}, {'lati': 77.196100000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.603400000000001}, {'lati': 77.302599999999998, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.6204}, {'lati': 77.088800000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.679600000000001}, {'lati': 77.1511, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.465499999999999}, {'lati': 77.217500000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.649799999999999}, {'lati': 77.119900000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.639700000000001}, {'lati': 77.174899999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.733599999999999}, {'lati': 77.226200000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.643000000000001}, {'lati': 77.224999999999994, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.6309}, {'lati': 77.204899999999995, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.569299999999998}, {'lati': 77.208600000000004, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.700199999999999}, {'lati': 77.292199999999994, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.668800000000001}, {'lati': 77.257400000000004, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.533200000000001}, {'lati': 77.256399999999999, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.5473}, {'lati': 77.180499999999995, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6478}, {'lati': 77.240499999999997, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.587399999999999}, {'lati': 77.144999999999996, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.630800000000001}, {'lati': 77.274600000000007, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.526800000000001}, {'lati': 77.142200000000003, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.725200000000001}, {'lati': 76.915599999999998, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.595700000000001}, {'lati': 77.120800000000003, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6266}, {'lati': 77.0608, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.709599999999998}, {'lati': 77.101900000000001, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.710000000000001}, {'lati': 77.240899999999996, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.559100000000001}, {'lati': 77.139099999999999, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.798999999999999}, {'lati': 77.164199999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.7258}, {'lati': 77.1524, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.5349}, {'lati': 77.165700000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.742899999999999}, {'lati': 77.042500000000004, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.796500000000002}, {'lati': 77.0518, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.724499999999999}, {'lati': 77.137799999999999, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.633600000000001}, {'lati': 77.214299999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.498899999999999}, {'lati': 77.1828, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.635000000000002}, {'lati': 77.1571, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.716799999999999}, {'lati': 77.159800000000004, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.684200000000001}, {'lati': 77.119299999999996, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.697800000000001}, {'lati': 77.208500000000001, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.665400000000002}, {'lati': 77.214299999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.629999999999999}, {'lati': 77.244200000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.592400000000001}, {'lati': 77.240600000000001, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.6419}, {'lati': 77.0916, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.6966}, {'lati': 77.306600000000003, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.666799999999999}, {'lati': 77.218800000000002, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.6556}, {'lati': 77.078599999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.7026}, {'lati': 77.276399999999995, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.6554}, {'lati': 77.221500000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.688500000000001}, {'lati': 77.174300000000002, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.692399999999999}, {'lati': 77.101399999999998, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.638999999999999}, {'lati': 77.082899999999995, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.588100000000001}, {'lati': 77.146600000000007, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.6601}, {'lati': 77.099500000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.609400000000001}, {'lati': 77.209299999999999, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.645800000000001}, {'lati': 77.211200000000005, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.654}, {'lati': 77.199100000000001, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.5745}, {'lati': 76.982699999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6098}, {'lati': 77.087199999999996, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.529599999999999}, {'lati': 77.317099999999996, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.613600000000002}, {'lati': 77.303600000000003, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.4938}, {'lati': 77.144099999999995, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.689}, {'lati': 77.207700000000003, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.6692}, {'lati': 77.206500000000005, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.692499999999999}, {'lati': 77.203199999999995, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.6386}, {'lati': 77.211200000000005, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.598299999999998}, {'lati': 77.240499999999997, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.5684}, {'lati': 77.280699999999996, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.667000000000002}, {'lati': 77.233699999999999, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.604199999999999}, {'lati': 77.313100000000006, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.655999999999999}, {'lati': 77.156199999999998, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.758400000000002}, {'lati': 77.232799999999997, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.554099999999998}, {'lati': 77.068299999999994, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.629999999999999}, {'lati': 77.064899999999994, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.625}, {'lati': 77.233400000000003, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.564699999999998}, {'lati': 77.292400000000001, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.562100000000001}, {'lati': 77.231499999999997, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.662500000000001}, {'lati': 77.290999999999997, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.5016}, {'lati': 77.281999999999996, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.540500000000002}, {'lati': 77.066999999999993, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.681999999999999}, {'lati': 77.198599999999999, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.558499999999999}, {'lati': 77.225499999999997, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6434}, {'lati': 77.066699999999997, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.578399999999998}, {'lati': 77.101200000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.671099999999999}, {'lati': 77.067400000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6205}, {'lati': 77.235399999999998, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.618200000000002}, {'lati': 77.119600000000005, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.651499999999999}, {'lati': 77.242999999999995, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.509599999999999}, {'lati': 77.303700000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.607299999999999}, {'lati': 77.078900000000004, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.747699999999998}, {'lati': 77.267300000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.659600000000001}, {'lati': 77.058499999999995, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.5641}, {'lati': 77.158699999999996, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.647500000000001}, {'lati': 77.036000000000001, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.6538}, {'lati': 77.227199999999996, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.5288}, {'lati': 77.270300000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.637799999999999}, {'lati': 77.295299999999997, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.638500000000001}, {'lati': 77.135099999999994, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.640499999999999}, {'lati': 77.208500000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.549399999999999}, {'lati': 77.022800000000004, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.8066}, {'lati': 77.120999999999995, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.730399999999999}, {'lati': 77.247200000000007, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.627400000000002}, {'lati': 77.225099999999998, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.575900000000001}, {'lati': 77.124399999999994, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.598700000000001}, {'lati': 77.193299999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6526}, {'lati': 77.113299999999995, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.657599999999999}, {'lati': 77.283900000000003, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.643599999999999}, {'lati': 77.158199999999994, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6524}, {'lati': 77.169300000000007, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.558}, {'lati': 77.193200000000004, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.6526}, {'lati': 77.260199999999998, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.578399999999998}, {'lati': 77.088499999999996, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.853200000000001}, {'lati': 77.311800000000005, 'type': 'Feature', 'properties': {'mag': 4}, 'longi': 28.598199999999999}, {'lati': 77.213700000000003, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.624700000000001}, {'lati': 77.071700000000007, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.664999999999999}, {'lati': 77.306100000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.625399999999999}, {'lati': 77.1785, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.680599999999998}, {'lati': 77.306100000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.625399999999999}, {'lati': 76.966800000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.628699999999998}, {'lati': 76.994699999999995, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.5869}, {'lati': 77.180199999999999, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.5215}, {'lati': 77.146000000000001, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.700399999999998}, {'lati': 77.081900000000005, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.628599999999999}, {'lati': 77.183700000000002, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.668399999999998}, {'lati': 77.192599999999999, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.670000000000002}, {'lati': 77.202600000000004, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.684999999999999}, {'lati': 77.152299999999997, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.5349}, {'lati': 77.118200000000002, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.7089}, {'lati': 77.332700000000003, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.6249}, {'lati': 77.316500000000005, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.678100000000001}, {'lati': 77.268600000000006, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.674299999999999}, {'lati': 77.298599999999993, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.6828}, {'lati': 77.285200000000003, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.674199999999999}, {'lati': 77.256100000000004, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.711099999999998}, {'lati': 77.291700000000006, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.696100000000001}, {'lati': 77.3185, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.706}, {'lati': 76.960800000000006, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.670400000000001}, {'lati': 77.264399999999995, 'type': 'Feature', 'properties': {'mag': 3}, 'longi': 28.7013}, {'lati': 77.272999999999996, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.679099999999998}, {'lati': 77.274799999999999, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.673400000000001}, {'lati': 77.308199999999999, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.698499999999999}, {'lati': 77.316000000000003, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.684999999999999}, {'lati': 77.262100000000004, 'type': 'Feature', 'properties': {'mag': 0}, 'longi': 28.672000000000001}, {'lati': 77.256100000000004, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.711300000000001}, {'lati': 77.274500000000003, 'type': 'Feature', 'properties': {'mag': 2}, 'longi': 28.732800000000001}, {'lati': 77.280799999999999, 'type': 'Feature', 'properties': {'mag': 1}, 'longi': 28.702200000000001}
];
var map;
var directionsDisplay;
var directionsService;
function initMap(location) {
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
var yourpos = new google.maps.LatLng(location.coords.latitude,location.coords.longitude);
map = new google.maps.Map(document.getElementById('map'), {
mapTypeControl: false,
zoom: 13,
center: yourpos,
});
var marker = new google.maps.Marker({
position: yourpos,
map: map
});
directionsDisplay.setMap(map)
new AutocompleteDirectionsHandler(map);
}
/**
* @constructor
*/
function AutocompleteDirectionsHandler(map) {
this.map = map;
this.originPlaceId = null;
this.destinationPlaceId = null;
this.travelMode = 'WALKING';
var originInput = document.getElementById('origin-input');
var destinationInput = document.getElementById('destination-input');
var modeSelector = document.getElementById('mode-selector');
this.directionsService = new google.maps.DirectionsService;
this.directionsDisplay = new google.maps.DirectionsRenderer;
this.directionsDisplay.setMap(map);
var originAutocomplete = new google.maps.places.Autocomplete(
originInput, {fields: ['place_id']});
var destinationAutocomplete = new google.maps.places.Autocomplete(
destinationInput, {fields: ['place_id']});
this.setupClickListener('changemode-walking', 'WALKING');
this.setupClickListener('changemode-transit', 'TRANSIT');
this.setupClickListener('changemode-driving', 'DRIVING');
this.setupPlaceChangedListener(originAutocomplete, 'ORIG');
this.setupPlaceChangedListener(destinationAutocomplete, 'DEST');
this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(originInput);
this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(destinationInput);
this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(modeSelector);
}
// Sets a listener on a radio button to change the filter type on Places
// Autocomplete.
AutocompleteDirectionsHandler.prototype.setupClickListener = function(id, mode) {
var radioButton = document.getElementById(id);
var me = this;
radioButton.addEventListener('click', function() {
me.travelMode = mode;
me.route();
});
};
AutocompleteDirectionsHandler.prototype.setupPlaceChangedListener = function(autocomplete, mode) {
var me = this;
autocomplete.bindTo('bounds', this.map);
autocomplete.addListener('place_changed', function() {
var place = autocomplete.getPlace();
if (!place.place_id) {
window.alert("Please select an option from the dropdown list.");
return;
}
if (mode === 'ORIG') {
me.originPlaceId = place.place_id;
} else {
me.destinationPlaceId = place.place_id;
}
me.route();
});
};
AutocompleteDirectionsHandler.prototype.route = function() {
if (!this.originPlaceId || !this.destinationPlaceId) {
return;
}
var me = this;
this.directionsService.route({
origin: {'placeId': this.originPlaceId},
destination: {'placeId': this.destinationPlaceId},
travelMode: this.travelMode,
provideRouteAlternatives: true,
unitSystem: google.maps.UnitSystem.METRIC
}, function(response, status) {
alert(status);
if (status == google.maps.DirectionsStatus.OK)
colors=["red","blue","black","green","yellow"];
var crimequo=[];
for (var p = 0, len = response.routes.length; p < len; p++) {
crimequo[p]=0;
var waypoints = response.routes[p].overview_path;
//console.log(response.routes);
new google.maps.DirectionsRenderer({
map: map,
directions: response,
routeIndex: p,
unitSystem: google.maps.UnitSystem.METRIC,
provideRouteAlternatives: true,
polylineOptions: {
strokeColor: colors[p],
strokeOpacity: 0.9,
strokeWeight: 7
}
});
var countofmarkers = 0;
for (var i = 0; i < waypoints.length; i++) {
for (var j = 0; j < getcrimequotient.length; j++) {
var roundofflat = getcrimequotient[j].lati.toString();
roundofflat=roundofflat.slice(0,(roundofflat.indexOf("."))+3);
var roundofflong = getcrimequotient[j].longi.toString();
roundofflong=roundofflong.slice(0,(roundofflong.indexOf("."))+3);
var roundoff2long = waypoints[i].lng().toString();
roundoff2long=roundoff2long.slice(0,(roundoff2long.indexOf("."))+3);
var roundoff2lat = waypoints[i].lat().toString();
roundoff2lat=roundoff2lat.slice(0,(roundoff2lat.indexOf("."))+3);
if ((roundofflat === roundoff2long) && (roundoff2lat === roundofflong))
{
countofmarkers++;
console.log("inside");
if(getcrimequotient[j].properties.mag==4){
crimequo[p]+=4;
console.log("inside4");
var marker = new google.maps.Marker({
position: new google.maps.LatLng(getcrimequotient[j].longi,getcrimequotient[j].lati),
map: map,
title:"Very dangerous",
icon:{
url: "http://maps.google.com/mapfiles/ms/icons/red-dot.png" }
//map:this
});
// marker.setMap(map);
}
else if(getcrimequotient[j].properties.mag==3){
crimequo[p]+=3;
console.log("inside3");
var marker = new google.maps.Marker({
position: new google.maps.LatLng(getcrimequotient[j].longi,getcrimequotient[j].lati),
map: map,
title:"dangerous",
icon:{
url: "http://maps.google.com/mapfiles/ms/icons/pink-dot.png" }
//map:this
}); }
else if(getcrimequotient[j].properties.mag==2){
crimequo[p]+=2;
console.log("inside2");
var marker = new google.maps.Marker({
position: new google.maps.LatLng(getcrimequotient[j].longi,getcrimequotient[j].lati),
map: map,
title:"crime-prone",
icon:{
url: "http://maps.google.com/mapfiles/ms/icons/yellow-dot.png" }
//map:this
}); }
else if(getcrimequotient[j].properties.mag==1){
crimequo[p]+=1;
var marker = new google.maps.Marker({
position: new google.maps.LatLng(getcrimequotient[j].longi,getcrimequotient[j].lati),
map: map,
title:"safe",
icon:{
url: "http://maps.google.com/mapfiles/ms/icons/blue-dot.png" }
//map:this
}); }
else if(getcrimequotient[j].properties.mag==0){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(getcrimequotient[j].longi,getcrimequotient[j].lati),
map: map,
title:"Very safe",
icon:{
url: "http://maps.google.com/mapfiles/ms/icons/green-dot.png" }
//map:this
}); }
}
}
}
crimequo[p]/=countofmarkers;
};
;
});
};
$(document).ready(function(){
navigator.geolocation.getCurrentPosition(initMap);
});
</script>
</body>
</html>