Hi there
I have a fairly simple problem I'm hoping someone can help me with. I have the following script
I am trying to set a global variable called my_lat and my_lng and have the geolocation function set these variables so that I can call them later on. For now I'm just writing to set that this is working properly but I'm just getting an undefined error.
What am I doing wrong here? Thanks!
NATE
I have a fairly simple problem I'm hoping someone can help me with. I have the following script
JavaScript:
<script>
var my_lat;
var my_lng;
function geo_success(position)
{
my_lat = position.coords.latitude;
my_lng = position.coords.longitude;
}
function geo_error()
{
alert("Sorry, no position available.");
}
var geo_options =
{
enableHighAccuracy: true,
maximumAge : 30000,
timeout : 27000
};
navigator.geolocation.watchPosition(geo_success, geo_error, geo_options);
document.write(my_lat);
</script>
I am trying to set a global variable called my_lat and my_lng and have the geolocation function set these variables so that I can call them later on. For now I'm just writing to set that this is working properly but I'm just getting an undefined error.
What am I doing wrong here? Thanks!
NATE