-
Notifications
You must be signed in to change notification settings - Fork 0
/
distancechecker.html
36 lines (29 loc) · 1.12 KB
/
distancechecker.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<!-- Include the jQuery library -->
<script src="js/jquery-1.11.3.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry"></script>
<script>
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
//alert(pos.lat + ' ' + pos.lng);
console.log(pos.lat + ' ' + pos.lng);
var desitination = new google.maps.LatLng(pos.lat, pos.lng);
var _kCord = new google.maps.LatLng(33.612134, 73.074094);
console.log(google.maps.geometry.spherical.computeDistanceBetween(_kCord, desitination));
}, function () {
alert('error');
});
}
</script>
</body>
</html>