Goodmorning, for my university cross platform project, I need to use the navigator.geolocation.getCurrentPosition() JS function to detect and work on the position. Reading on internet (and on the teacher' slides), I understood that this function that calls out a callback function, so I'm trying with some console.log.
$("#update").click(function() {
console.log(navigator.geolocation.getCurrentPosition(function(position) {do_something(position.coords.latitude, position.coords.longitude);}));
});
The result: UNDEFINED. What am I doing wrong?
SOLVED
The problem is with my browser: I don't know why, but it waits some seconds to ask me "Allow position" and it caused me these problems.