问题描述
我使用的科尔多瓦3.0.0,一个三星Galaxy S3 4.1.2进行测试。
I am using Cordova 3.0.0, A Samsung Galaxy S3 4.1.2 to test.
在我测试的PhoneGap完整的例子为观看位置:http://docs.phonegap.com/en/edge/cordova_geolocation_geolocation.md.html#geolocation.watchPosition
When I test the Phonegap full example for watching position : http://docs.phonegap.com/en/edge/cordova_geolocation_geolocation.md.html#geolocation.watchPosition
我得到COORDS一条第一线,然后我得到了错误:
I get one first line with coords, and then I got the error :
code 3
message : Position retrieval timed out.
和任何其他位置返回。在我的iPhone同样的code的工作。我测试行走时,当我在一个汽车,同样的事情。
And no other location are returned. The same code on my iphone is working.I am testing when walking, and when I was in a car, same thing.
我注意到,当我使用谷歌地图的Android设备上,一个GPS图标弹出最上面一栏。当我启动我的应用程序,这是不是在这里。
I noticed that when I use google maps on the android device, a gps icons pops up on the top bar.When I launch my app, it is not here.
清单是正确设置了权限,我的选择是:
The Manifest is correctly set up with permissions, and my options are :
var options = { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true };
watchID = navigator.geolocation.watchPosition( onSuccess, onError, options );
我需要precision我的应用程序工作...
I need precision for my app to work...
感谢您的帮助。
推荐答案
好了,以后的测试时间,我设法让Android上watchPosition工作,科尔多瓦3.1.0。
Ok, so after hours of tests, I managed to make the watchPosition work on Android with Cordova 3.1.0 .
您需要做什么:使用HTML5唯一的API地理位置,并不包括这样的:http://cordova.apache.org/docs/en/3.1.0/cordova_geolocation_geolocation.md.html#Geolocation
What you have to do: Use the html5 only api for geolocation and do not include this : http://cordova.apache.org/docs/en/3.1.0/cordova_geolocation_geolocation.md.html#Geolocation
如果你已经拥有了它在你谟,通过CLI将其删除: 科尔多瓦插件RM org.apache.cordova.geolocation
If you already have it in your projet, remove it via the CLI : cordova plugin rm org.apache.cordova.geolocation
当然,让那些线在你的Android清单:
Of course, keep those lines in your android manifest :
< uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
< uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
< uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
这是为我工作,所以告诉我,如果它为你工作。如果你需要,我将发布code(但科尔多瓦完整的示例工程为例)
This is working for me, so tell me if its working for you. I will post code if you need ( but the cordova full example works for example )
这篇关于PhoneGap的Android的地理位置watchPosition超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!