-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetEmpLocation.php
157 lines (131 loc) · 3.94 KB
/
setEmpLocation.php
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
<script>
function initMap() {
// alert("sd");
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("Geolocation is not supported by this browser. Map related service will not work.");
}
}
var lattlong;
var latt;
var long;
var maps;
var icon;
var markers;
var address;
let id= <?php echo $user['id']; ?>;
function showPosition(position) {
markers.setMap(null)
latt = position.coords.latitude;
long = position.coords.longitude;
lattlong = new google.maps.LatLng(latt, long);
const geocodingUrl = `https://maps.googleapis.com/maps/api/geocode/json?latlng=${latt},${long}&key=AIzaSyCdk0GkRdoCCpgU-T_rBFoU_CFPWB5KnBM`;
fetch(geocodingUrl)
.then(response => response.json())
.then(data => {
address = data.results[0].formatted_address;
});
markers =
new google.maps.Marker({
position: lattlong,
map: maps,
title: "Location",
animation: google.maps.Animation.BOUNCE,
icon: icon
});
console.log("SD");
}
google.charts.load("current", {
packages: ["corechart"]
});
google.charts.setOnLoadCallback(drawChart);
$(document).ready(function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition1);
} else {
alert("Geolocation is not supported by this browser. Map related service will not work.");
}
// initMap();
})
function showPosition1(position) {
latt = position.coords.latitude;
long = position.coords.longitude;
lattlong = new google.maps.LatLng(latt, long);
var myOptions = {
center: lattlong,
zoom: 15,
mapTypeControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
}
maps = new google.maps.Map(document.getElementById("myMap"), myOptions);
icon = {
url: "images/truck.gif", // url
scaledSize: new google.maps.Size(50, 50), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
markers =
new google.maps.Marker({
position: lattlong,
map: maps,
title: "Location",
animation: google.maps.Animation.BOUNCE,
icon: icon
});
}
function drawChart() {
let pr;
let c;
$.ajax({
url: 'admin/controller/empGraph.php',
type: 'post',
async: false,
data: {
id: id
},
success: function(resp) {
let obj = JSON.parse(resp);
console.log(obj)
pr = obj.pendingReq;
c = obj.complete;
a = obj.accept;
}
})
let latt = 0;
let long = 0;
var data = google.visualization.arrayToDataTable([
['Request', 'Status'],
['Pending', pr],
['Compete', c],
['Accepted', a],
]);
var options = {
title: 'My Daily Activities',
pieHole: 0.4,
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
setInterval(initMap,2000);
let flag=0;
setInterval(function(){
if(flag==1){
$.ajax({
url:'fireLocation.php',
type:'post',
data:{
lat:latt,
lon:long,
address:address,
id:id
},
success:function(resp){
console.log(address);
}
})
}
},2000);
</script>