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

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

问题描述

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

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。

  1. User does not have GPS/Location Services enabled.
  2. User opens the application and navigates to the view that calls navigator.geolocation to get the user's position
  3. The app errors out and notifies the user they must enable GPS/Location Services
  4. The user then navigates out of the app and enables GPS
  5. When the user comes back to the app and tries to view the map (calling the geolocation again) the app still isn't able to use 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 $ c>。

Try just to call 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天全站免登陆