Hello i want to return latitude and longitude of my current position from a function i tried the following method to accomplish it,But it doesn't return any value. Do you have any alternate method?. Please help me out..
here is some part from my code...
//calling the function
var myloc=current_location();
alert(myloc.lat1);
function current_location(){
var my_loc = {};
navigator.geolocation.getCurrentPosition(function(position) {
var geocoder = new google.maps.Geocoder();
pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var lat1=position.coords.latitude;
var lon1=position.coords.longitude;
my_loc.lat1 =lat1;
my_loc.lon1 =lon1;
});
return my_loc;
}