-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_template.tpl
114 lines (108 loc) · 3.06 KB
/
index_template.tpl
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
<!DOCTYPE html>
<html>
<head>
<title>Fake it!</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0px;
padding: 0px
}
#map-canvas {
height: 100%;
}
#inputContainer {
height: 200px;
min-height: 200px;
width: 300px;
margin: 50px;
position: absolute;
bottom: 0px;
right: 0px;
z-index: 999;
background-color: white;
-moz-border-radius: 15px;
border-radius: 15px;
}
#form {
padding:10px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
var map;
var marker;
function initialize() {
var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(52.511818,13.455856),
noClear: true
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
draggable:true,
title: 'Drag me'
});
google.maps.event.addListener(marker, 'dragend', function()
{
console.log("marker dragged");
sendUpdate();
});
}
function sendUpdate(){
markerPos = marker.getPosition()
$.ajax({
type: 'POST',
url: '/ajax/send/location',
data: JSON.stringify({location: {'latitude':markerPos.lat(),'longitude':markerPos.lng(),'speed':$('#speed').val(),'course':$('#course').val(),'altitude':$('#altitude').val()},device:{'ip':$('#ip').val(),'port':$('#port').val()}}),
contentType: 'application/json',
success: function(response) {
console.log("sent location " + marker.position);
}
});
}
$(document).ready(function(){
$('#ip').bind('change', function(){
sendUpdate()
});
$('#port').bind('change', function(){
sendUpdate()
});
$('#speed').bind('change', function(){
sendUpdate()
});
$('#course').bind('change', function(){
sendUpdate()
});
$('#altitude').bind('change', function(){
sendUpdate()
});
});
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas">
<div id="inputContainer">
<div id="form">
<label for="ip">IP:</label>
<input type="text" id="ip"><br>
<label for="port">Port:</label>
<input type="text" id="port" value="9931"><br>
<label for="speed">Speed:</label>
<input type="text" id="speed" value="0"><br>
<label for="course">Course:</label>
<input type="text" id="course" value="0"><br>
<label for="altitude">Altitude:</label>
<input type="text" id="altitude" value="0">
</div>
</div>
</div>
</body>
</html>