I searching to 开发者_C百科return the position.coords outside the scope of the function navigator.geolocation.getCurrentLocation(getLocation,err). I have tried using window vars but i'm not able, all values are always locals. Can someone point the way. Thanks
I assume you mean getCurrentPosition
. If you just need the coordinates, you can do this.
return coords.clone();
Update
getCurrentPosition
requires a callback function. You can use it something like this:
navigator.geolocation.getCurrentPosition(function(pos) {
alert(pos.coords.latitude+","+pos.coords.longitude);
});
精彩评论