????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.55 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/apps/school/OLD/PokemonGo/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<title>Geolocation</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
#map {
height: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
<script>
var map, infoWindow, marker;
var routePositions = [];
var isBusStarted = false;
var testPositionsFromDB = "17.710578,83.316997$17.711344,83.316327$17.712233,83.315468$17.713138,83.314983"
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 18
});
marker = new google.maps.Marker({
map: map,
animation: google.maps.Animation.DROP,
});
locateUser();
//setTimeout(timer_called, 3000)
}
function locateUser()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function(position)
{
var pos = {lat: position.coords.latitude, lng: position.coords.longitude};
map.setCenter(pos);
marker.setPosition(pos);
if (isBusStarted)
{
routePositions.push(pos);
printLocations()
setTimeout(locateUser, 3000)
}
},
function()
{
handleLocationError(true, infoWindow, map.getCenter());
});
}
else
{
handleLocationError(false, infoWindow, map.getCenter());
}
}
function printLocations()
{
var positions = "";
for (index=0; index<routePositions.length; index++)
{
var position = routePositions[index];
positions += /*"\n" + */position.lat + "," + position.lng + "$";
}
positions = positions.substring(0, positions.length - 1);
//alert(message)
updateToDB(positions)
}
function handleLocationError(browserHasGeolocation, infoWindow, pos)
{
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
infoWindow.open(map);
}
function updateToDB(positions)
{
//This is working but only one time as it is updating the url with arguments
//location.href = "http://appsrv.astacus.se/apps/school/OLD/PokemonGo/updateBoundaryPoints.php?ParentId=95&BoundaryPointsString='" + positions + "'"
//This is also working
$.ajax({
url: "http://appsrv.astacus.se/apps/school/OLD/PokemonGo/updateBoundaryPoints.php?ParentId=95&BoundaryPointsString='" + positions + "'"
}).done(function(data) {
console.log(data);
});
}
function startBus()
{
isBusStarted = true;
routePositions = [];
setTimeout(locateUser, 3000)
}
function stoppedBus()
{
isBusStarted = false;
routePositions = [];
}
function showBusRoute()
{
/*var url = "http://appsrv.astacus.se/apps/school/OLD/PokemonGo/getBoundaryPoints.php?ParentId=95"
$.ajax({
url: 'http://20percents.com/created_by_mohan/testAll.php',
type: 'GET',
data: { fields: "title" },
success: function(data) {
//called when successful
$('body').html(data);
},
error: function(e) {
}
});*/
/*var jqxhr = $.get( url, function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.always(function() {
alert( "second finished" );
});*/
}
</script>
<div>For Driver: </div>
<input type="button" name="enviar" value="Start Bus" onclick="startBus()">
<input type="button" name="enviar" value="Stopped Bus" onclick="stoppedBus()">
<div></div>
<div>For Parent: </div>
<input type="button" name="enviar" value="Show Bus Route" onclick="showBusRoute()">
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAQMI0qgSwIQ2Ijsolw1PYwFjkbO4SAwYI&callback=initMap">
</script>
</body>
</html>