Cordova插件Geolocation不适用于Android版本Kitkat [英] Cordova plugin Geolocation is not working for Android version Kitkat

查看:65
本文介绍了Cordova插件Geolocation不适用于Android版本Kitkat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了cordova插件地理位置: https://github.com/apache/cordova-plugin-geolocation

I have used the cordova plugin geolocation: https://github.com/apache/cordova-plugin-geolocation

通过命令安装cordova插件:cordova插件添加org.apache.cordova.geolocation

Install the plugin of cordova by command: cordova plugin add org.apache.cordova.geolocation

在关闭位置的Android版本Jelly Bean(三星Galaxy Tab 2 4.1.2 Jelly Bean,Samsung Galaxy Grand 2版本4.1.2 Jelly Bean)中运行正常,但在Android版本Kitkat(三星Note 2)中无法正常工作版本4.4.2 Kitkat).

It is working fine in Android version Jelly Bean (Samsung Galaxy Tab 2 version 4.1.2 Jelly Bean, Samsung Galaxy Grand 2 version 4.1.2 Jelly Bean) with location off but is not working in Android version Kitkat (Samsung Note 2 version 4.4.2 Kitkat).

 navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError);
       function geolocationSuccess(position) {
           var latlng = "Latitude :" + position.coords.latitude + ", Longitude :" + position.coords.longitude);
           $ionicPopup.alert({
               title: "User Current Location",
               subTitle: "Location",
               template: latlng
           });
       }

       function geolocationError(error) {
           $ionicPopup.alert({
                   title: "Pajhwok Location",
                   subTitle: "Error",
                   template: JSON.stringify(error)
           });
       }

推荐答案

@laughingpine 所述,这将有助于确切了解您遇到的问题.

As @laughingpine says, it would help to know exactly what the issue is you're encountering.

您说关闭位置后,它在Android版本Jelly Bean(三星Galaxy Tab 2 4.1.2 Jelly Bean,三星Galaxy Grand 2版本4.1.2 Jelly Bean)中工作正常,但在Android版本Kitkat(Samsung Note 2版本4.4.2 Kitkat)."

You said "It is working fine in Android version Jelly Bean (Samsung Galaxy Tab 2 version 4.1.2 Jelly Bean, Samsung Galaxy Grand 2 version 4.1.2 Jelly Bean) with location off but is not working in Android version Kitkat (Samsung Note 2 version 4.4.2 Kitkat)."

这是否表示在Android 4.4.2上,位置关闭时未执行错误回调?还是在开启位置服务时执行了错误回调而不是成功回调?如果是这样,请给我们错误输出.

By this do you mean that on Android 4.4.2 the error callback is not being executed when location is off? Or that the error callback is being executed instead of success callback when location services is on? If so, please give us the error output.

如果是后者,则可以尝试显式设置maxAge和超时,例如

If the latter, you can try explicitly setting maxAge and timeout, e.g.

navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError, {maxAge: 30000, timeout: 60000});

这篇关于Cordova插件Geolocation不适用于Android版本Kitkat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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