开发者

GeoLocation HTML5 return position.coords outside scope of getCurrentLocation

开发者 https://www.devze.com 2023-03-20 21:33 出处:网络
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

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);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消