科尔多瓦地理位置插件没有得到位置,距离GPS为Android [英] Cordova geolocation plugin not getting location from GPS for Android

查看:162
本文介绍了科尔多瓦地理位置插件没有得到位置,距离GPS为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的科尔多瓦应用程序,我想从GPS获取用户的位置。对于我使用地理位置插件。我需要每10秒后得到的位置。我做的是这样的:

in my Cordova application, I am trying to get user's location from GPS. For that I am using Geolocation plugin. I need to get location after every 10 seconds. I am doing something like:

navigator.geolocation.getCurrentPosition(
                      $rootScope.onSuccessForLocation,
                      $rootScope.onErrorForLocation_High,
                      {maximumAge:600000, timeout:7000, enableHighAccuracy: true}
                      );

现在,当这个code运行时,它给我的位置在回调方法,但它不是从未来GPS的应用程序时,应该开始出现在GPS图标开始闪烁状态栏。但情况并非如此。 我有一个旧的应用程序是使用相同的插件。当我启动应用程序,GPS图标开始闪烁。我注意到,到目前为止有一件事是,在旧的应用程序,我可以看到在Android项目的Geolocation.java文件,但在最新的插件没有这样的文件了,甚至我试图寻找它在Github上源文件夹。现在,我不知道什么是失踪在我的身边。有没有人有想法发生了什么事?

Now when this code runs, it gives me location in callback method but its not coming from GPS as when app starts the GPS icon should appear and starts blinking in status bar. But it is not happening. I had an old app which is using same plugin. When I start that app, GPS icon starts blinking. One thing that I have noted so far is that in old app, I can see the Geolocation.java file in android project but there is no such file in latest plugin anymore even I tried to search it in the Github source folders. Now, I don't know what is missing on my side. Does anyone have idea what is happening?

推荐答案

他们使用的是HTML5地理位置实施,而不是原生code。 他们取消了Android的Java code上的插件版本0.3.7

They are using HTML5 geolocation implementation instead of native code. They removed the android java code on release 0.3.7 of the plugin

### 0.3.7 (Apr 17, 2014)
* CB-6422: [windows8] use cordova/exec/proxy
* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
* CB-5977: [android] Removing the Android Geolocation Code.  Mission Accomplished.
* CB-6460: Update license headers
* Add NOTICE file

如果你想使用,其中本地code使用了插件的旧版本,你可以安装像这样

If you want to use an older version of the plugin where the native code was used you can install it like this

cordova plugin add org.apache.cordova.geolocation@0.3.6

这篇关于科尔多瓦地理位置插件没有得到位置,距离GPS为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆