Sorted, just for the life of me am battling to call a php app, pass the gps info, and return, so it can continue tracking.
I have the below, but when it calls the php app ([SIZE=12px]agenttrack.php)[/SIZE], the [SIZE=12px]agenttrack.php[/SIZE] does it job then seems to freeze the main app. Been battling all day on this. Can you advise?
[SIZE=12px]var watchID;[/SIZE]
[SIZE=12px]var geoLoc;[/SIZE]
[SIZE=12px]getLocationUpdate();[/SIZE]
[SIZE=12px]function showLocation(position) {[/SIZE]
[SIZE=12px]var latitude = position.coords.latitude;[/SIZE]
[SIZE=12px]var longitude = position.coords.longitude;[/SIZE]
[SIZE=12px]var accuracy = position.coords.accuracy;[/SIZE]
[SIZE=12px]var heading = position.heading;[/SIZE]
[SIZE=12px]var speed = position.speed;[/SIZE]
[SIZE=12px]alert("Latitude : " + latitude + " Longitude: " + longitude);[/SIZE]
[SIZE=12px]$.ajax({[/SIZE]
[SIZE=12px]type:‘POST’,[/SIZE]
[SIZE=12px]url:'https://secure.XXXXXX.com/agenttrack/agenttrack.php?latX=’+latitude+’&lngY=’+longitude+’&accuracy=’+accuracy+’&heading=’+heading+’&speed=’+speed;[/SIZE]
[SIZE=12px]});[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]function errorHandler(err) {[/SIZE]
[SIZE=12px]if(err.code == 1) {[/SIZE]
[SIZE=12px]alert(“Error: Access is denied!”);[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]else if( err.code == 2) {[/SIZE]
[SIZE=12px]alert(“Error: Position is unavailable!”);[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]function getLocationUpdate(){[/SIZE]
[SIZE=12px]if(navigator.geolocation){[/SIZE]
[SIZE=12px]// timeout at 60000 milliseconds (60 seconds)[/SIZE]
[SIZE=12px]var options = {timeout:60000};[/SIZE]
[SIZE=12px]geoLoc = navigator.geolocation;[/SIZE]
[SIZE=12px]watchID = geoLoc.watchPosition(showLocation, errorHandler, options);[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]else{[/SIZE]
[SIZE=12px]alert(“Sorry, browser does not support geolocation!”);[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]} [/SIZE]