离子应用中的纬度经度

时间:2016-06-06 06:29:06

标签: android angularjs ionic-framework

我尝试使用离子框架在移动应用程序的当前位置获取经度和经度。但它在浏览器中获得了确切的价值但是当我在移动设备中构建时,我发现未定义的纬度经度。我使用了$ cordovaGeolocation插件。这是下面的代码,

GetCurrentAddress();
        $timeout(function() {
            var data = {
                longitude: $scope.longitude,
                latitude: $scope.latitude
            }
            // console.log(data)
        }, 10000);

    // Get the current address
    function GetCurrentAddress() {

        $ionicPlatform.ready(function () {

            var posOptions = {
                enableHighAccuracy: false,
                timeout: 50000,
                maximumAge: 0
            };
            $cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
                var lat = position.coords.latitude;
                var long = position.coords.longitude;

                $scope.latitude = lat;
                $scope.longitude = long;

            }, function (err) {
                console.log(err);
            });

        });

    };

我已经尝试了很多但找不到任何解决方案。有没有其他方法可以在我的位置使用离子框架获取移动应用程序的纬度经度?

0 个答案:

没有答案