仅从 GPS 获取 iPhone 上的位置 - 而不是 wifi 网络

发布于 2024-09-06 21:37:44 字数 351 浏览 2 评论 0原文

我正在创建一个使用位置的应用程序 -

除了一件事之外,一切都运行顺利 -

当我回到家时,我的 iPhone 连接到我的本地 wifi 网络,而不是使用手机中的 GPS 来获取我的位置,而是尝试通过找出我的位置来获取我的位置。 wifi 网络已连接到 - 如果我关闭 wifi,它会保留准确的位置点 -

一旦我的手机连接到我的 wifi 网络,它就会开始告诉我我的位置距离我的实际位置有几公里/英里。

我希望我的应用程序不要使用 wifi 网络来尝试获取我的位置 -

有什么办法可以 - 一个。判断位置点是否源自 GPS,这样我就可以忽略源自 wifi 网络的位置。 b.停止定位服务跳转到 wifi 进行定位

i am creating an app that uses location-

everything works swimmingly except one thing-

when i come home my iphone connects to my local wifi network and instead of getting my location using the gps in the phone it tries to get it by figuring out where my wifi network is connected to- if i turn my wifi off it keeps an accurate location point-

as soon as my phone is connected to my wifi network it starts telling me my location is several km/miles from my actual point.

i would like my app NOT to use the wifi network to try get my location-

is there a way i can-
a. tell if a location point has been derived from the GPS so i can ignore locations derived from the wifi network.
b. stop location services jumping over to wifi for location

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

呆头 2024-09-13 21:37:44

好吧,我做了一些尝试,

发现一些苹果文档说 [location VerticalAccuracy] 需要带有 GPS 的设备。

因此,我将这段代码插入(删节),并且根据我所做的有限测试,它似乎正在做我想要的事情:

if (([location horizontalAccuracy] > 0) && ([location verticalAccuracy] > 0)){
     //report location here
}

感谢大家的回复。

Well I did some playing around

Found some apple documentation that says that [location verticalAccuracy] REQUIRES a device with gps.

So I stuck this code in (abridged) and based on the limited testing I have done, it appears to be doing what I want:

if (([location horizontalAccuracy] > 0) && ([location verticalAccuracy] > 0)){
     //report location here
}

Thanks all for your replies.

你另情深 2024-09-13 21:37:44

除了要求用户关闭 Wifi 之外,没有任何记录在案的方法可以强制位置管理器通过 Wifi 使用 GPS。使用私有 API 可能是可行的,但这也会让你被 App Store 拒绝。

Other than asking the user to turn off his Wifi, there's no documented way you can force the location manager to use GPS over Wifi. It might be possible with private API, but that would also get you rejected from the App Store.

清晨说晚安 2024-09-13 21:37:44

您可以设置 cLLocationAccuracy.desiredAccuracy = kCLLocationAccuracyBest 并查看是否有效。它应该尝试限制 GPS 的使用,但这并不能 100% 保证。

You can set cLLocationAccuracy.desiredAccuracy = kCLLocationAccuracyBest and see if that does it. It should try and limit to GPS use, however that isn't 100% guarenteed.

仄言 2024-09-13 21:37:44

它在家中使用 WIFI 的原因是因为它无法直接看到太空中的 GPS 卫星 - 它不是不向您提供任何位置数据,而是使用下一个最佳的可用来源。

The reason it uses WIFI at home is because there's no way it can have direct sight of the GPS satellites out in space - instead of not giving you any location data, it uses the next best available source.

月依秋水 2024-09-13 21:37:44

iPhone不仅可以通过Wi-Fi或移动网络获取不准确的GPS坐标,还可以获取精度等级>100米的真实坐标。

我使用的是放置以下行: if (newLocation.horizo​​ntalAccuracy < 0 || newLocation.horizo​​ntalAccuracy > 50) return;

作为 didUpdateToLocation 中的第一行,以过滤掉不准确的坐标。

“位置年龄”即 NSTimeInterval locationAge=[locTimestamp timeIntervalSinceNow]; 不能帮助我摆脱缓存的坐标。

the inaccurate GPS coordinates are obtained by the iPhone not only via the Wi-Fi or mobile networks, but also the real-coordinates with accuracy level >100 metres.

What I use is to put the line: if (newLocation.horizontalAccuracy < 0 || newLocation.horizontalAccuracy > 50) return;

as the first line in the didUpdateToLocation, to filter out inaccurate coordinates.

The 'location age' i.e. NSTimeInterval locationAge=[locTimestamp timeIntervalSinceNow]; does NOT serve for me to get rid of cached coordinates.

眼藏柔 2024-09-13 21:37:44

A-GPS = GPS + 手机信号塔三角测量。没有WI-FI定位。

A-GPS = GPS + cell tower triangulation. There is no WI-FI positioning.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文