Sto cercando di creare una funzione che restituisce un oggetto con le informazioni di un callback:Attendere la richiamata in javascript
var geoloc;
var successful = function (position) {
geoloc = {
longitude: position.coords.longitude,
latitude: position.coords.latitude
};
};
var getLocation = function() {
navigator.geolocation.getCurrentPosition(successful, function() {
alert("fail");
});
return geoloc;
};
Come posso fare questo? La funzione getLocation
restituisce un valore nullo prima che venga eseguito successful
.
Grazie!
Hai troppe '}' in 'getLocation'. –
Modificato, grazie! – palvarez89
Hai troppi 'l' e troppo pochi' s' in 'riuscito' ...;) –