I'm using this function with google maps
var currgeocoder;
navigator.geolocation.getCurrentPosition(function (position, html5Error) {
geo_loc = processGeolocationResult(position);
currLatLong = geo_loc.split(",");
initializeCurrent(currLatLong[0], currLatLong[1]);
});
function processGeolocationResult(position) {
html5Lat = position.coords.latitude; //Get latitude
html5Lon = position.coords.longitude; //Get longitude
html5TimeStamp = position.timestamp; //Get timestamp
html5Accuracy = position.coords.accuracy; //Get accuracy in meters
return html5Lat + ", " + html5Lon;
}
alert(html5Lat);
As you see I didn't use var
to make the variable global, but the alert()
doesn't work and if I place the alert()
inside the function it works well. So how to make the html5lat
and html5lon
global to be accessed from another function?