Angularjs iOS模拟器GPS不工作?

Angularjs iOS模拟器GPS不工作?,angularjs,cordova,gps,Angularjs,Cordova,Gps,我在iOS模拟器中测试了我的应用程序,发现gps不工作。 在emulator中,我将位置设置为“Apple” 并通过以下方式安装corodova插件:“cordova plugin add org.apache.cordova.geolocation” 这是我的密码: angular.module('home', ['services']) .controller('homeCtrl', function ($scope, $location, $state, serverAPI, $

我在iOS模拟器中测试了我的应用程序,发现gps不工作。 在emulator中,我将位置设置为“Apple” 并通过以下方式安装corodova插件:“cordova plugin add org.apache.cordova.geolocation”

这是我的密码:

angular.module('home', ['services'])

.controller('homeCtrl',
    function ($scope, $location, $state, serverAPI, $ionicPopup) {

        $scope.buttonType = "icon ion-search";
        $scope.buttonDisable = false;
        $scope.text = 'Search';
        var UID = JSON.parse(window.localStorage.getItem('Credentials')).UID;
        serverAPI.getUserData(UID, function (data) {
            $scope.userName = data.userName;
            $scope.points = data.points;
            $scope.fotoId = data.fotoId;
            console.log(data);
        });



        $scope.click = function () {
            $scope.buttonDisable = true;
            $scope.text = 'Searching';
            $scope.buttonType = 'icon ion-loading-a';



            //            //Grap geoLocation        
            var location = navigator.geolocation.getCurrentPosition(saveGeoData, onError);
            //

            function onError(error) {
                alert('code: ' + error.code + '\n' +
                    'message: ' + error.message + '\n');
            };

            var saveGeoData = function (geoData) {
                console.log("nach geo");
                var myPosition = {
                    'longitude': geoData.coords.longitude,
                    'latitude': geoData.coords.latitude
                };
                console.log("ss");
                console.log(myPosition.latitude);
                window.localStorage.setItem('myPosition', JSON.stringify(myPosition));
                //If geoloaction is saved successfully => Send geodata to server to receive teammate
                sendToServer(myPosition);
            }


            //Send current location to Server to receive teammate
            var sendToServer = function (myPosition) {
                serverAPI.searchPartnerToPlayWith(myPosition.longitude, myPosition.latitude, UID, function (data) {

                    //No other players around you. Server returns -1 
                    if (data == -1) {
                        $ionicPopup.alert({
                            title: 'Too bad :(',
                            template: 'Unfortunateley there are no other players around you. Try it some other time!'
                        });
                    } else {
                        window.localStorage.setItem('teammate', data.username);
                        window.localStorage.setItem('isEnummeration', data.taskType);
                        window.localStorage.setItem('task', data.task);
                        var teammatePosition = {
                            'longitude': data.longitude,
                            'latitude': data.latitude
                        };
                        window.localStorage.setItem('teammatePosition', teammatePosition);
                        //TODO: data.fotoId => request foto from server
                        $state.go('tab.play-screen');
                    }


                })
            }
        };

    })
调用函数click时,它会在以下行中停止:

var location = navigator.geolocation.getCurrentPosition(saveGeoData, onError);
你猜我有什么问题吗?在浏览器中,它可以正常工作。
谢谢

确保将此文件包含到项目中

这可能是一个高概率的原因,因为在您的项目中不存在此函数,
getCurrentPosition