I'm working in Google Earth Engine and I want to access the user's location to then be able to use the position when visualizing data layers. When running the code below, GEE doesn't seem to be able to understand the navigator which contains the geolocation info I'm looking for. Same goes for document. This makes me wonder whether GEE even works in JS since it doesn't understand the queries(?) Anyone with a solution to access the user location?
var locationButton = ui.Button('User location');
locationButton.onClick(function() {
var startPos;
var geoSuccess = function(position) {
startPos = position;
document.getElementById('startLat').innerHTML = startPos.coords.latitude;
document.getElementById('startLon').innerHTML = startPos.coords.longitude;
if (navigator.geolocation) {
console.log('Geolocation is supported!');
}
else {
console.log('Geolocation is not supported for this Browser/OS.');
}
};
navigator.geolocation.getCurrentPosition(geoSuccess);
});
Map.add(locationButton);