HI !!
I am trying to get GPS coordinates using JS.
In the index.html file, I have added a function in JS that I am running in the project.
However, I am not getting the correct data. Why ?
My JS function
function getLocation() {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var positionInfo = "Your current position is (" + "Latitude: " + position.coords.latitude + ", " + "Longitude: " + position.coords.longitude + ")";
return positionInfo;
});
} else {
alert("Sorry, your browser does not support HTML5 geolocation.");
}
}
Code in Defold
function on_input(self, action_id, action)
if action_id == hash("touch") then
if html5 then
local ss = html5.run("getLocation()")
print ("loc: " .. ss)
end
end
end
and what I see in the console logs