English 中文(简体)
Telephonegap Geoplace 错误:时间
原标题:Phonegap Geolocation Error: timeout

我用最新的电话交换1.2,并在我的申请中将测试代码从笔试中删除。 当我对模拟器(xcode 4.2 simulator 5.0)和我的iPad(5号)进行了评估时,我发现错误“Geoposition Error:timeout”。

是否有其他人经历过这种情况? 我的守则是:

document.addEventListener("deviceready", onDeviceReady, false);
        // PhoneGap is ready
        function onDeviceReady() {
        var myOptions = { enableHighAccuracy: true };
        navigator.geolocation.getCurrentPosition(onSuccess, onError,myOptions);}

感谢!

问题回答

我认为,在文件输入问题上,你失踪。 你们需要进口<条码>电话gap-1.2.0.js,而不是<条码>电话gap.j。

在5台模拟器和装置上进行氮化工作。

<!DOCTYPE html>
<html>
    <head>
        <title>Device Properties Example</title>
        <script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
        <script type="text/javascript" charset="utf-8">
            // Wait for PhoneGap to load
            document.addEventListener("deviceready", onDeviceReady, false);
            // PhoneGap is ready
            function onDeviceReady() {
                 var myOptions = { enableHighAccuracy: true };
                navigator.geolocation.getCurrentPosition(onSuccess, onError,myOptions);
            }
            // onSuccess Geolocation
            function onSuccess(position) {
                var element = document.getElementById( geolocation );
                element.innerHTML =  Latitude:             + position.coords.latitude              +  
+ Longitude: + position.coords.longitude +
+ Altitude: + position.coords.altitude +
+ Accuracy: + position.coords.accuracy +
+ Altitude Accuracy: + position.coords.altitudeAccuracy +
+ Heading: + position.coords.heading +
+ Speed: + position.coords.speed +
+ Timestamp: + new Date(position.timestamp) +
; } // onError Callback receives a PositionError object function onError(error) { alert( code: + error.code + + message: + error.message + ); } </script> </head> <body> <p id="geolocation">Finding geolocation...</p> </body> </html>

i Mayur的答复显示,非本土的地籍图人正在工作。 如果你第一次打电话给该笔记本,将请浏览器超额5台复印机提出“大地点接入问题”。

I think here is a bigger issue in phonegap: Issuetracker #197

[EDIT]

There is a new issue opened: Issuetracker #304

Don t know if they fixed it for you. Now assuming that your code is correct: navigator.geolocation.getCurrentPosition(onSuccess, onError,{ enableHighAccuracy :true, timeout :10000}); Add the timeout part, and it shouldnt give a timeout error anymore.





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签