Phonegap 在应用程序运行时启用 GPS/位置 [英] Phonegap enable GPS/Location at app runtime

查看:17
本文介绍了Phonegap 在应用程序运行时启用 GPS/位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jquery-ui-maps 和 HTML5 地理位置向用户显示位置列表,我需要利用用户的地理位置.

I am using jquery-ui-maps and HTML5 geolocation to show to the user a list of locations and I need to leverage the user's geolocation.

所以,这里是用例,

  1. 用户未启用 GPS/定位服务.
  2. 用户打开应用程序并导航到调用 navigator.geolocation 的视图 获取用户的位置
  3. 应用出错并通知用户他们必须启用 GPS/定位服务
  4. 然后用户退出应用并启用 GPS
  5. 当用户返回应用并尝试查看地图(再次调用地理位置)时,应用仍然无法使用 GPS.

我相信我已将其范围缩小为一个 Phonegap 问题,其中 GPS 权限在应用加载时初始化并且从未重新评估.

I believe I have narrowed it down to being a Phonegap issue where the GPS permissions are initialized at app load and never reevaluated.

我的问题是,能否在应用程序运行期间启用 GPS,或者 Phonegap 是否需要重新加载应用程序才能使用 GPS?

My question is, can GPS be enabled during the runtime of the application or does Phonegap require an app reload to use the GPS?

推荐答案

Phonegap 确实支持 GPS 的实时更新.

Phonegap does support realtime update of your GPS.

这是一个直接链接:

http://docs.phonegap.com/en/3.1.0/cordova_geolocation_geolocation.md.html#geolocation.watchPosition

一般称为观看位置",您可以自己设置刷新计时器.

In general its called "watch position", and you can set the refresh timer yourself.

关于在运行期间启用 GPS.

Regarding enabling the GPS during runtime.

尝试只调用 navigator.geolocation.watchPosition().

请记住在您的 config.xml 上也授予对地理位置的访问权限,但我想您知道 ;)

Remember to grant access to geolocation on your config.xml as well, but I guess you know that ;)

希望对你有所帮助.

这篇关于Phonegap 在应用程序运行时启用 GPS/位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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