tags:

views:

26

answers:

0

Hi,

I'm trying to load the values returned by geolocation into a few labels in an asp.net page. The following function is getting called on onload(), but doesn't always return a value. I thought by passing a callback function like I am this would handle the asynchronous nature of the call, but I must be missing something. Any help would be great!

if (navigator.geolocation) {
                browserSupportFlag = true;
                navigator.geolocation.getCurrentPosition(
                        function(position) {
                            document.getElementById("lblStatus").innerHTML = "Location found using W3C standard";
                            document.getElementById("lblLon").innerHTML = position.coords.longitude;
                            document.getElementById("lblLat").innerHTML = position.coords.latitude;
                            document.getElementById("lblAccuracy").innerHTML = position.coords.accuracy;
                        }, function() {
                            handleNoGeolocation(browserSupportFlag);
                        });
            }