Hi,
i’m tryng to implement and application which intercepts the user’s coordinates saving them in global variables.
The coordinates are calculated by html5 and navigator.geolocation and the initial application should be a Dashboard.with a menu.
How to save the coordinates in global variables to be used as filter in grid queries ?
Regards
Gianpaolo
You an do something like this in JavaScript funtion, OnLoad
var watchID;
var geoLoc;
setInterval(function() {
getLocationUpdate();
} , 15000);
function showLocation(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var accuracy = position.coords.accuracy;
var heading = position.heading;
var speed = position.speed;
$.post( “…your api url…”, { lngY: longitude, latX: latitude } );
}
function errorHandler(err) {
if(err.code == 1) {
alert(“Error: Access is denied!”);
}
else if( err.code == 2) {
alert(“Error: Position is unavailable!”);
}
}
function getLocationUpdate(){
if(navigator.geolocation){
// timeout at 60000 milliseconds (60 seconds)
var options = {enableHighAccuracy: false, timeout:5000, maximumAge: 0};
geoLoc = navigator.geolocation;
watchID = geoLoc.getCurrentPosition(showLocation, errorHandler, options);
}
else{
alert(“Sorry, browser does not support geolocation!”);
}
}