forked from vgartner/gps-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimated.html
More file actions
179 lines (143 loc) · 3.98 KB
/
Copy pathanimated.html
File metadata and controls
179 lines (143 loc) · 3.98 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
<script>
var count = 0;
var countmarker = 0;
var arrLength = 0;
var from = 0;
var to = 0;
var map;
var markerBounds = new google.maps.LatLngBounds();
var randomPoint, i
var path;
//Buscar dados do banco
opcao = " query="+
"select * "+
" from gprmc "+
" where imei = '358899051381880' "+
" and date between '2014-12-17 00:06' and '2014-12-18 00:30'"+
" order by date ";
$.ajax({
type: "GET",
url: "http://128.199.163.160/services.php",
dataType:"text",
data:opcao,
async:false,
success:function(response){
//console.log(response);
var dados = $.parseJSON(response);
firstPoint(dados[0].latitudeDecimalDegrees, dados[0].longitudeDecimalDegrees);
setDataMap(dados);
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
function setDataMap(arr)
{
console.log(arr.length);
arrLength = arr.length;
window.setInterval(function (){writeMap(arr)},500);
}
function writeMap(rowArr)
{
if (count < arrLength) {
if (count > 1 )
{
from = new google.maps.LatLng(rowArr[count-1].latitudeDecimalDegrees, rowArr[count-1].longitudeDecimalDegrees);
to = new google.maps.LatLng(rowArr[count].latitudeDecimalDegrees, rowArr[count].longitudeDecimalDegrees);
if (rowArr[count-1].latitudeDecimalDegrees != rowArr[count].latitudeDecimalDegrees)
{
countmarker++;
if (countmarker<10)
{
pin = 'http://google-maps-icons.googlecode.com/files/black0'+countmarker+'.png';
}
else
{
pin = 'http://google-maps-icons.googlecode.com/files/black'+countmarker+'.png';
}
path.push(to);
var marker = new google.maps.Marker({
position: to,
draggable: false,
animation: google.maps.Animation.DROP,
title: '#' + path.getLength(),
icon: pin,
label:'uai',
map: map
});
var contentString =
'<table width="100%" border="0" cellpadding="3" cellspacing="2" bgcolor="#f4f4f4"> '+
' <tr> '+
' <td colspan="2" align="center" class="titulos" bgcolor="#CCCCCC">Informações sobre a posição</td> '+
' </tr> '+
' <tr> '+
' <td width="8%" class="titulos">Data / Hora</td> '+
' <td width="86%"> </td> '+
' </tr> '+
' <tr> '+
' <td class="titulos">Posição:</td> '+
' <td> </td> '+
' </tr> '+
' <tr> '+
' <td class="titulos">Velocidade:</td> '+
' <td class="tbInformacoes"> </td> '+
' </tr> '+
' <tr> '+
' <td class="titulos">Endereço:</td> '+
' <td class="tbInformacoes"> </td> '+
' </tr> '+
'</table> ';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
map.panTo(to);
}
}
count++;
}
}
function firstPoint(lat,long)
{
var mapOptions = {
zoom: 19,
center: new google.maps.LatLng(lat, long)
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(lat, long),
title:"Hello World!"
});
var polyOptions = {
strokeColor: '#000000',
strokeOpacity: 1.0,
strokeWeight: 1
};
poly = new google.maps.Polyline(polyOptions);
poly.setMap(map);
path = poly.getPath();
}
</script>