forked from onury/geolocator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
449 lines (422 loc) · 28.8 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
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Geolocator JS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/flatly/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/css/bootstrap3/bootstrap-switch.min.css">
<link rel="stylesheet" href="css/example.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="../dist/geolocator.js"></script>
<script type="text/javascript" src="js/example.js"></script>
</head>
<body>
<div class="container">
<div id="page-content" class="row">
<h2>Geolocator v2 Examples</h2>
<hr />
Below is just a demonstration of some Geolocator features.
This does not fully cover all Geolocator methods and options.
For all capabilities and more, please read the
<b><a target="_top" href="https://onury.github.io/geolocator?api=geolocator">API documentation</a></b>.
<div id="alert-https" class="hidden alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Warning!</strong> HTML5 Geolocation API <a target="_blank" href="https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only?hl=en">requires a secure origin</a> in some browsers.
For methods like <code>geolocator.locate()</code> to work properly <a target="_top" href="https://onury.github.io/geolocator/?content=examples">click here to reload</a> the page with <b>HTTPS</b> protocol.
</div>
<h3>Geolocator Configuration</h3>
<code>geolocator.config(options)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.config"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<br />
<br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-5">
<div class="input-group">
<span class="input-group-addon mw-120">Language</span>
<select id="sel-lang" class="form-control">
<option value="en" selected>English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="es">Spanish</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="pt">Portuguese</option>
<option value="ru">Russian</option>
<option value="tr">Turkish</option>
</select>
</div>
<div class="input-group">
<span class="input-group-addon mw-120">HTTPS</span>
<input id="chk-config-https" type="checkbox" checked />
</div>
</div>
<div class="col-sm-7">
<div class="input-group">
<span class="input-group-addon mw-170">Google API Key</span>
<input id="txt-config-gk" type="password" class="form-control" placeholder="YOUR-API-KEY" value="" />
<!-- ENTER YOUR OWN GOOGLE API KEY. DO NOT USE THE DEMO KEY IN YOUR APPLICATION!!! -->
</div>
<div class="input-group">
<span class="input-group-addon mw-170">Google Maps Version</span>
<input id="txt-config-gversion" type="text" class="form-control" placeholder="Google Maps Version" value="3" />
</div>
</div>
</div>
</div>
<div id="btn-menu" class="btn-group nowrap" data-toggle="buttons">
<label class="btn btn-primary btn-sm active" data-api="locate" data-caption="Locate (HTML5)">
<input type="radio" name="menu" id="option1" autocomplete="off" checked> Locate
</label>
<label class="btn btn-primary btn-sm" data-api="locateByIP" data-caption="Locate by IP">
<input type="radio" name="menu" id="option2" autocomplete="off"> by IP
</label>
<label class="btn btn-primary btn-sm" data-api="locateByMobile" data-caption="Locate by Mobile">
<input type="radio" name="menu" id="option3" autocomplete="off"> by Mobile
</label>
<label class="btn btn-primary btn-sm" data-api="geocode" data-caption="Geocode">
<input type="radio" name="menu" id="option3" autocomplete="off"> Geocode
</label>
<label class="btn btn-primary btn-sm" data-api="reverseGeocode" data-caption="Address Lookup">
<input type="radio" name="menu" id="option3" autocomplete="off"> Address
</label>
<label class="btn btn-primary btn-sm" data-api="getTimeZone" data-caption="Get TimeZone">
<input type="radio" name="menu" id="option3" autocomplete="off"> Time Zone
</label>
<label class="btn btn-primary btn-sm" data-api="getDistanceMatrix" data-caption="Get Distance Matrix">
<input type="radio" name="menu" id="option3" autocomplete="off"> D. Matrix
</label>
<label class="btn btn-primary btn-sm" data-api="calcDistance" data-caption="Calculate Distance">
<input type="radio" name="menu" id="option3" autocomplete="off"> Distance
</label>
<label class="btn btn-primary btn-sm" data-api="getIP" data-caption="Get Public IP">
<input type="radio" name="menu" id="option3" autocomplete="off"> Public IP
</label>
</div>
<div class="menu-content">
<div class="menu-panel hidden active" id="panel-locate">
<h3>Geo-Location (HTML5)</h3>
<code>geolocator.locate(options, callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.locate"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Enabling marked options requires a Google API Key" aria-hidden="true"></span>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-7">
<div class="input-group">
<span class="input-group-addon mw-170">Enable High Accuracy</span>
<input id="chk-html5-accuracy" type="checkbox" checked />
</div>
<div class="input-group">
<span class="input-group-addon mw-170">Desired Accuracy</span>
<input id="txt-html5-desired" type="number" class="form-control w-150" placeholder="Desired Accuracy" value="30" />
<span class="unit">meters</span>
</div>
<div class="input-group">
<span class="input-group-addon mw-170">Timeout</span>
<input id="txt-html5-timeout" type="number" class="form-control w-150" placeholder="Timeout" value="6000" />
<span class="unit">milliseconds</span>
</div>
<div class="input-group">
<span class="input-group-addon mw-170">Maximum Wait</span>
<input id="txt-html5-wait" type="number" class="form-control w-150" placeholder="Maximum Wait" value="10000" />
<span class="unit">milliseconds</span>
</div>
<div class="input-group">
<span class="input-group-addon mw-170">Maximum Age</span>
<input id="txt-html5-maxage" type="number" class="form-control w-150" placeholder="Maximum Age" value="0" />
<span class="unit">milliseconds</span>
</div>
</div>
<div class="col-sm-5">
<div class="input-group">
<span class="input-group-addon mw-150">
Fallback to IP
</span>
<input id="chk-html5-ip" type="checkbox" />
</div>
<div class="input-group">
<span class="input-group-addon mw-150">
Address Lookup <span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Requires a Google API Key if enabled" aria-hidden="true"></span>
</span>
<input id="chk-html5-lookup" type="checkbox" />
</div>
<div class="input-group">
<span class="input-group-addon mw-150">
Time Zone <span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Requires a Google API Key if enabled" aria-hidden="true"></span>
</span>
<input id="chk-html5-timezone" type="checkbox" />
</div>
<div class="input-group">
<span class="input-group-addon mw-150">
Create Map <span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Requires a Google API Key if enabled" aria-hidden="true"></span>
</span>
<input id="chk-html5-map" type="checkbox" />
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-locateByIP">
<h3>Geo-Location by IP</h3>
<code>geolocator.locateByIP(options, callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.locateByIP"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Enabling marked options requires a Google API Key" aria-hidden="true"></span>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-160">
Address Lookup <span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Requires a Google API Key if enabled" aria-hidden="true"></span>
</span>
<input id="chk-ip-lookup" type="checkbox" />
</div>
<div class="input-group">
<span class="input-group-addon mw-160">
Time Zone <span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Requires a Google API Key if enabled" aria-hidden="true"></span>
</span>
<input id="chk-ip-timezone" type="checkbox" />
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-160">
Create Map <span class="glyphicon glyphicon-asterisk pointer text-warning" data-toggle="tooltip" title="Requires a Google API Key if enabled" aria-hidden="true"></span>
</span>
<input id="chk-ip-map" type="checkbox" />
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-locateByMobile">
<h3>Geo-Location by Mobile Client</h3>
<code>geolocator.locateByMobile(options, callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.locateByMobile"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-asterisk pointer text-danger" data-toggle="tooltip" title="Method requires a Google API Key" aria-hidden="true"></span>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-180">Mobile Country Code</span>
<input id="txt-mobile-ccode" type="number" class="form-control" placeholder="Home Mobile Country Code" value="310" />
</div>
<div class="input-group">
<span class="input-group-addon mw-180">Mobile Network Code</span>
<input id="txt-mobile-ncode" type="number" class="form-control" placeholder="Home Mobile Network Code" value="410" />
</div>
<div class="input-group">
<span class="input-group-addon mw-180">Mobile Carrier</span>
<input id="txt-mobile-carrier" type="text" class="form-control" placeholder="Carrier" value="Vodafone" />
</div>
<div class="input-group">
<span class="input-group-addon mw-180">Mode</span>
<select id="cmb-mobile-radio" class="form-control">
<option value="lte">LTE</option>
<option value="gsm" selected>GSM</option>
<option value="cdma">CDMA</option>
<option value="wcdma">WCDMA</option>
</select>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-140">Fallback to IP</span>
<input id="chk-mobile-ip" type="checkbox" checked /><label for="chk-mobile-ip">
</div>
<div class="input-group">
<span class="input-group-addon mw-140">Address Lookup</span>
<input id="chk-mobile-lookup" type="checkbox" />
</div>
<div class="input-group">
<span class="input-group-addon mw-140">Time Zone</span>
<input id="chk-mobile-timezone" type="checkbox" />
</div>
<div class="input-group">
<span class="input-group-addon mw-140">Create Map</span>
<input id="chk-mobile-map" type="checkbox" />
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-geocode">
<h3>Geocoding — Coordinates from Address</h3>
<code>geolocator.geocode(options, callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.geocode"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-asterisk pointer text-danger" data-toggle="tooltip" title="Method requires a Google API Key" aria-hidden="true"></span>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<span class="input-group-addon mw-160">Address</span>
<input id="txt-geocode-address" type="text" class="form-control" placeholder="Address" value="1600 Amphitheatre Parkway, CA" />
</div>
<div class="input-group">
<span class="input-group-addon mw-160">Create Map</span>
<input id="chk-geocode-map" type="checkbox" />
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-reverseGeocode">
<h3>Reverse Geocoding — Address Lookup from Coordinates</h3>
<code>geolocator.reverseGeocode(options, callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.reverseGeocode"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-asterisk pointer text-danger" data-toggle="tooltip" title="Method requires a Google API Key" aria-hidden="true"></span>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-12">
<div class="form-inline">
<div class="input-group">
<span class="input-group-addon mw-120">Latitude</span>
<input id="txt-lookup-lat" type="number" class="form-control" placeholder="Latitude" value="40.714224" />
</div>
<div class="input-group">
<span class="input-group-addon mw-120">Longitude</span>
<input id="txt-lookup-lon" type="number" class="form-control" placeholder="Longitude" value="-73.961452" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-getTimeZone">
<h3>Time Zone from Coordinates</h3>
<code>geolocator.getTimeZone(options, callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.getTimeZone"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-asterisk pointer text-danger" data-toggle="tooltip" title="Method requires a Google API Key" aria-hidden="true"></span>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
<span class="input-group-addon">Coordinates</span>
<select id="cmb-timezone-cities" class="form-control">
</select>
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-getDistanceMatrix">
<h3>Distance Matrix and Duration</h3>
<code>geolocator.getDistanceMatrix(options, callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.getDistanceMatrix"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<span class="glyphicon glyphicon-asterisk pointer text-danger" data-toggle="tooltip" title="Method requires a Google API Key" aria-hidden="true"></span>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-120">Origin</span>
<select id="cmb-distmatrix-cities-a" class="form-control">
</select>
</div>
<div class="input-group">
<span class="input-group-addon mw-120">Destination</span>
<select id="cmb-distmatrix-cities-b" class="form-control">
</select>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-80">Mode</span>
<select id="cmb-distmatrix-mode" class="form-control">
<option value="DRIVING" selected>Driving</option>
<option value="WALKING">Walking</option>
<option value="BICYCLING">Bicycling</option>
<option value="TRANSIT">Transit</option>
</select>
</div>
<div class="input-group">
<span class="input-group-addon mw-80">Unit</span>
<select id="cmb-distmatrix-unit" class="form-control">
<option selected>Metric</option>
<option>Imperal</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-calcDistance">
<h3>Distance Calculation</h3>
<code>geolocator.calcDistance(options)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.calcDistance"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-100">From</span>
<select id="cmb-distance-cities-a" class="form-control">
</select>
</div>
<div class="input-group">
<span class="input-group-addon mw-100">To</span>
<select id="cmb-distance-cities-b" class="form-control">
</select>
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon mw-100">Formula</span>
<select id="cmb-distance-formula" class="form-control">
<option value="haversine" selected>Haversine</option>
<option value="pythagorean">Pythagorean</option>
</select>
</div>
<div class="input-group">
<span class="input-group-addon mw-100">Unit</span>
<select id="cmb-distance-unit" class="form-control">
<option selected>Metric</option>
<option>Imperal</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="menu-panel hidden" id="panel-getIP">
<h3>Public IP Address</h3>
<code>geolocator.getIP(callback)</code>
<a data-toggle="tooltip" title="Click for documentation and code example" target="_top" href="https://onury.github.io/geolocator?api=geolocator#geolocator.getIP"><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"></span></a>
<br /><br />
<div class="well form-horizontal">
<div class="form-group">
<i>This method has no options.</i>
</div>
</div>
</div>
</div>
<button id="btn-exec" type="button" class="btn btn-success btn-block">Locate (HTML5)</button>
<br />
<div id="map-canvas" class="hidden"></div>
<div class="text-center">Check your console for response result...</div>
</div>
</div>
<br />
<br />
<div id="footer">
<div id="footer-inner">
<table>
<tr>
<td>Geolocator v2 - Copyright © 2018, <a target="_blank" href="https://github.com/onury">Onur Yıldırım</a>. MIT License.</td>
<td><a class="github-button" href="https://github.com/onury/geolocator" data-size="large" data-show-count="true" aria-label="Star onury/geolocator on GitHub">Star</a></td>
</tr>
</table>
</div>
</div>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>