小编hei*_*hei的帖子

geolocation.getCurrentPosition 如何返回值?

我正在使用 getCurrentPosition 来获取当地的纬度和经度。我知道这个函数是异步的,只是想知道如何返回其他函数可以访问的纬度和经度值?

    function getGeo() {
        navigator.geolocation.getCurrentPosition(getCurrentLoc)
    }

    function getCurrentLoc(data) {
        var lat,lon;
        lat=data.coords.latitude;
        lon=data.coords.longitude;
        getLocalWeather(lat,lon)
        initMap(lat,lon)
    }
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous geolocation

6
推荐指数
1
解决办法
6382
查看次数

标签 统计

asynchronous ×1

geolocation ×1

javascript ×1