Javascript地理位置 - GPS设置 - FINE vs COARSE [英] Javascript geolocation - GPS settings - FINE vs COARSE

查看:142
本文介绍了Javascript地理位置 - GPS设置 - FINE vs COARSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我如何显示地理位置如果手机中的GPS未处于活动状态,设备的设置如何?

  2. 如何知道返回的经纬度值是来自GPS还是来自wifi /数据线?我认为wifi / data返回一个短值(例如:43.475748),并且GPS返回一个更长的值(例如:43.47573849384)我是否正确地考虑了这一点?


解决方案

最后一个已知的地理位置。不幸的是,这种行为并不一致,除了尝试记住应用程序中的最后一个已知位置之外,您无法做出任何更改。



2。 )我不认为HTML5地理API提供了详细程度,但您可以查看提供的准确性信息。 精细与粗略的指定有些混乱,因为它意味着在不同设备和操作系统上(跨平台应用程序的性质)有所不同。我会使用准确性反馈作为相关指南。



如果您想使用地理位置功能,请在XDK中签出hello-cordova示例应用程序,使用它可以很方便地查看地理特征在各种设备上的工作方式。您可以在App Preview中使用它,或者只需构建应用程序并将其安装在各种设备上。请注意,如果您先按下精细按钮,则观看按钮将检索精细结果。如果您在按下观看按钮之前按下粗略按钮,观看结果将基于粗略设置。

一般而言,最好首先请求一个粗略读数(用一个短暂的超时时间)来获得一个普通的位置(或一个缓存的位置),然后在需要更精确的位置时切换到良好的请求。如果您坚持不频繁的粗略读数,尤其是如果您只需要知道用户的一般位置(例如,他们位于哪个城镇或社区),电池寿命会更好。

I am creating a geolocation app with Intel XDK (iPhone and Android) and have 2 questions:

  1. How can I display the geolocation settings of the device if the GPS is not active on the phone?
  2. How do I know if the latitude and longitude values returned are from the GPS or from the wifi/data coords? I figured that wifi/data returns a short value (eg: 43.475748) and GPS returns a longer value (eg: 43.47573849384) Am I correct in thinking this?

解决方案

1.) Most devices will cache the last known geo location. Unfortunately, this behavior is not consistent, and there's not much you can do to change that other than attempt to remember a set of last known locations within your app.

2.) I don't think the HTML5 geo API provides that level of detail, but you could look at the accuracy information that is provided. The designation of "fine" versus "coarse" is somewhat arbritraty, since it means different things on different devices and operating systems (the nature of cross-platform applications). I would use the accuracy feedback as a relative guide.

If you want to play with the geo location feature, checkout the "hello-cordova" sample app in the XDK, it is very easy to use to see how the geo feature works on a variety of devices. You can use it in App Preview or simply build the app and install it on a variety of devices. Note that if you first push the "fine" button then the "watch" button will retrieve "fine" results. If you push the "coarse" button before pushing the "watch" button the watch results will be based on a "coarse" setting.

In general, it is best to first request a "coarse" reading (with a short timeout) to get a general location (or a cached location) and then switch to a "fine" request if you need a more precise location. Battery life will be better if you stick to infrequent "coarse" readings, especially if you only need to know the general location of your user (for example, in which town or neighborhood are they located).

这篇关于Javascript地理位置 - GPS设置 - FINE vs COARSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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