2

am having task to find the geo location for get the current position.the problem am facing is when i run the app first time it shows the answer,if i run the app as repeatedly means it shows error:

code: 2
message: The operation couldn’t be completed. (kCLErrorDomain error 0.)

the code is given below:

document.addEventListener("deviceready", onDeviceReady, false);

            var watchID = null;

            // PhoneGap is ready
            //
            function onDeviceReady() {
                // Update every 3 seconds
                var options = { frequency: 3000 };
                watchID = navigator.geolocation.getPosition(onSuccess, onError, options);
            }

            // onSuccess Geolocation
            //
            function onSuccess(position) {
                alert(position);
                var element = document.getElementById('geolocation');
                element.innerHTML = 'Latitude: '  + position.coords.latitude      + '<br />' +
                'Longitude: ' + position.coords.longitude     + '<br />' +
                '<hr />'      + element.innerHTML;
            }

            // onError Callback receives a PositionError object
            //
            function onError(error) {
                alert('code: '    + error.code    + '\n' +
                      'message: ' + error.message + '\n');
                console.log('code: '    + error.code    + '\n' +
                            'message: ' + error.message + '\n');
            }

i run the app only in simulator.i don't know whats going wrong?

4

1 回答 1

0

该错误意味着您失去了连接。通过运行我的应用程序,然后进入飞行模式,我得到了这个错误。希望有帮助。

于 2013-12-10T16:17:11.150 回答