You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Everyone,
I'd like to know if is possible with Shiny Mobile the access of mobile geography coordinates (GPS hardware unit) and extract this information? My final goal is in a given geographic coodinate in a map the Shiny Mobile go to this coordinate of interest.
Thanks in advance.
Alexandre
The text was updated successfully, but these errors were encountered:
To obtain the device's GPS location, you can use this javascript.
$(document).ready(function () {
function getLocation(callback){
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
navigator.geolocation.getCurrentPosition(
onSuccess,
onError,
options
);
function onError (err) {
Shiny.onInputChange("errormess", err.message);
Shiny.onInputChange("geolocation", false);
}
function onSuccess (position) {
setTimeout(function () {
var coords = position.coords;
var timestamp = new Date();
console.log(coords.latitude + ", " + coords.longitude, "," + coords.accuracy);
Shiny.onInputChange("geolocation", true);
Shiny.onInputChange("lat", coords.latitude);
Shiny.onInputChange("long", coords.longitude);
Shiny.onInputChange("accuracy", coords.accuracy);
Shiny.onInputChange("time", timestamp)
console.log(timestamp);
if (callback) {
callback();
}
}, 1100)
}
}
var TIMEOUT = 1000; //SPECIFY
var started = false;
function getLocationRepeat(){
//first time only - no delay needed
if (!started) {
started = true;
getLocation(getLocationRepeat);
return;
}
setTimeout(function () {
getLocation(getLocationRepeat);
}, TIMEOUT);
};
getLocationRepeat();
});
Save it as a file (e.g. "myJSfile.js) and put it in your project folder. On your UI, put includeScript("myJSfile.js") and then you will get input$geolocation == TRUE when you have the device's location and you can also call input$lat, input$long, input$accuracy, and input$time. All are updated for the specified interval.
Hi Everyone,
I'd like to know if is possible with Shiny Mobile the access of mobile geography coordinates (GPS hardware unit) and extract this information? My final goal is in a given geographic coodinate in a map the Shiny Mobile go to this coordinate of interest.
Thanks in advance.
Alexandre
The text was updated successfully, but these errors were encountered: