Monday, 19 August 2013

Real Time mySQL, PHP Google Maps API Update

Real Time mySQL, PHP Google Maps API Update

I have an android app sending gps coordinates in a 1 sec. Interval to php
and then mysql on a server. Them i have a site where location of the
device can be tracked in real time on google maps. The problem is that
when i call the php script to query new coordinates in mysql, it runs
perfect the first time and gives me the latest coordinates to use on
google maps, but after the first loop , it keep on givimg me the same
value , even if the database has been updated.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Horse Tracker © 2013 Abiapps</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" href="style.css" rel="stylesheet"
media="all" />
<script
type="text/javascript"src="http://maps.google.com/maps/api/js?********&sensor=false"></script>
<script type="text/javascript" src="map.js"></script>
<meta name="viewport" content="initial-scale=1.0,
user-scalable=no" />
</head>
<body>
<h1>Horse Tracker © 2013 Abiapps </h1>
<input type="button" value="getValues" id="getValues" />
<input type="button" value="changeValues" id="changeValues" />
<div id="map"></div>
<script>
(function() {
window.onload = function() {
var mapDiv = document.getElementById('map');
var latlng = new google.maps.LatLng(35.694094,23.683620);
var options = {
center: latlng,
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: true,
navigationControl: true,
navigationControlOptions: {
position: google.maps.ControlPosition.TOP_RIGHT
},
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
streetViewControl: false,
backgroundColor: '#0000ff'
};
var map = new google.maps.Map(mapDiv, options);
document.getElementById('getValues').onclick = function() {
alert('Current Zoom level is ' + map.getZoom());
alert('Current center is ' + map.getCenter());
}
document.getElementById('changeValues').onclick = function() {
var latLng = new google.maps.LatLng(<?php include
'getgps.inc.php';?>);
map.setCenter(latLng);
}
var a = 1;
function autoUpdate() {
a = a;
var latLng = new google.maps.LatLng(<?php include
'getgps.inc.php';?>);
map.setCenter(latLng);
alert('<?php include 'getgps.inc.php';?>');
setTimeout(autoUpdate, 1000);
}
autoUpdate();
}
})();
</script>
</body>
</html>
and the php code..
im getting the same result in alert(); as the firt query even if i add row
to the database

No comments:

Post a Comment