Meteor的cordova:geolocation插件不能在手机上工作 [英] Meteor's cordova: geolocation plugin doesn't work on mobile

查看:187
本文介绍了Meteor的cordova:geolocation插件不能在手机上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Meteor(1.2.0.2)应用程式部署到Android装置。



我是以

安装插件

  meteor add cordova:cordova-plugin-geolocation@1.0.0 


b $ b


添加Cordova插件cordova-plugin-geolocation@1.0.0。


I使用的插件:

  document.addEventListener(deviceready,onDeviceReady,false); 
function onDeviceReady(){
navigator.geolocation.getCurrentPosition(function(p){// onSuccess
console.log(p);
},function(e){
console.log(e);
});
}

在桌面上完美地打印(打印p作为Geolocation对象)忽略回调(包括成功和错误)。



我通过设置断点在Chrome DevTools( chrome:// inspect 它会一直到.getCurrentPosition调用,然后(跳过或步进)只是跳过这两个回调(如果我在其中设置一个断点,他们只是没有命中)。



我甚至尝试过

  navigator.geolocation.getCurrentPosition(function(p){console.log(p); 

 

> undefined
地理位置{...}

工作)

 未定义
//不打印其他内容

可能与应用程式的权限有关吗?



EDIT :我已验证 AndroidManifest.xml ,且权限实际上由插件设置:

 < uses-permission android:name =android.permission.ACCESS_COARSE_LOCATION/> 
< uses-permission android:name =android.permission.ACCESS_FINE_LOCATION/>


解决方案

@dragonmnl,



GPS不可靠



你没有谈论超时,我必须假设你没有设置超时足够长。尝试将其设置为约20秒 - 至少。



如果您的阅读不佳,或者您已逾时





  • 确保您清楚地查看所有视野(无阻挡视图)

  • 走在一个大圆,直径约15英尺



在大约30-45秒内,你应该有一个阅读。
当你阅读我给你的链接时,这将是有意义的。



Jesse


I'm deploying my Meteor (1.2.0.2) app to an Android device.

I installed the plugin by

 meteor add cordova:cordova-plugin-geolocation@1.0.0

Added Cordova plugin cordova-plugin-geolocation@1.0.0.

I used the plugin by:

    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        navigator.geolocation.getCurrentPosition(function(p){ // onSuccess
            console.log(p);
        }, function(e){
            console.log(e);
        });
    }

On desktop works perfectly (print p as Geolocation object) but on mobile it just ignores the callbacks (both success and errors).

I tested it in Chrome DevTools (chrome://inspect) by setting breakpoints. It steps until .getCurrentPosition call but then (either step over or step in) just skips both callbacks (and If I set a breakpoint within them, they are just not hit).

I even tried

navigator.geolocation.getCurrentPosition(function(p){ console.log(p); 

both on Desktop console (works)

undefined
Geolocation { ... }

and mobile (does not work)

undefined
// nothing else is printed

Maybe has it something to do with app's permissions?

EDIT: I verified AndroidManifest.xml and the permissions are actually set by the plugin:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

解决方案

@dragonmnl,

GPS is unreliable.

You did not talk about timeout, I must assume you have NOT set the timeout long enough. Try setting it to about 20 seconds -- as a minimum.

If your readings are poor, or you are timing out

  • go outside
  • make sure you have a clear view of all horizons (nothing blocking the view)
  • walk in a big circle, about 15ft in diameter

In about 30-45 seconds you should have a reading. This will make sense when you read the link I gave you.

Jesse

这篇关于Meteor的cordova:geolocation插件不能在手机上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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