-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlive.html
84 lines (76 loc) · 2.5 KB
/
live.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
<!DOCTYPE html>
<html>
<head>
<title>Live location in Map </title>
<style>
.gfg {
font-size: 100px;
font-weight: bold;
color: #009900;
margin-left: 20px;
}
.geeks {
margin-left: 150px;
}
p {
font-size: 20px;
margin-left: 20px;
}
</style>
</head>
<body>
<div class="gfg"></div>महिला रक्षक</div>
<p>Live location in map</p>
<button class="geeks" type="button" onclick="getlocation();">
Current Position</button>
<div id="demo2" style="width: 500px; height: 500px;">
</div>
<script src="https://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function getlocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showLoc, errHand);
}
}
function showLoc(pos) {
latt = pos.coords.latitude;
long = pos.coords.longitude;
var lattlong = new google.maps.LatLng(latt, long);
var OPTions = {
center: lattlong,
zoom: 10,
mapTypeControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
}
var mapg = new google.maps.Map(document.getElementById("demo2"), OPTions);
var markerg =
new google.maps.Marker({
position: lattlong,
map: mapg,
title: "You are here!"
});
}
function errHand(err) {
switch (err.code) {
case err.PERMISSION_DENIED:
result.innerHTML = "The application doesn't have the permission" +
"to make use of location services"
break;
case err.POSITION_UNAVAILABLE:
result.innerHTML = "The location of the device is uncertain"
break;
case err.TIMEOUT:
result.innerHTML = "The request to get user location timed out"
break;
case err.UNKNOWN_ERROR:
result.innerHTML = "Time to fetch location information exceeded" +
"the maximum timeout interval"
break;
}
}
</script>
</body>
</html>