如何在屏幕上显示指南针?

发布于 2024-12-08 08:42:26 字数 267 浏览 0 评论 0 原文

我是 iOS 开发新手。我的目标是在屏幕上显示指南针。我有某个位置的纬度和经度。我已经使用 CLLocation 获取了当前的纬度和经度。

我已经使用 API 计算了两点之间的距离,但现在我想知道手机的正确方向 N/S/E/W 以及类似根据正确北极的方向...我不确定。

iPhone北极和实际北极有什么概念吗?

我想显示一条指向特定经度和纬度的线,即使我的手机正在旋转或移动;该线仅指向该点。

请帮助我,我现在应该去哪里? 任何指导或链接/图都会很棒。

I am new to iOS development. My objective is to show a compass on Screen. I have a latitude and longitude of a certain location. I have gotten my current latitude and longitude by using CLLocation.

I have calculated the distance between two points using an API, but now I want to know the correct direction of my phone N/S/E/W and something like according to correct north pole... I am not sure.

Is there some concept of iPhone north pole and actual north pole?

I want show a line pointing towards the particular longitude and latitude, even if my phone is rotating or moving; the line points towards that point only.

Please help me, where i should proceed now?
Any guidance or links/tut will be great.

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

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

发布评论

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

评论(1

沫离伤花 2024-12-15 08:42:26

这称为 CLLocation 的“标题”。

请参阅CLLocationManager 文档部分为您的应用程序配置标题并调用startUpdatingHeading 收到标题更改的通知,即当您的 iPhone 指向另一个点时。

然后使用标准的 CLLocationManagerDelegate 方法来了解标题更改并相应地重新绘制线条。

请阅读位置感知编程指南,了解有关位置服务和标题的更多信息,尤其是这部分甚至包含示例代码。


PS:关于两个不同的北,没有“iPhone北极”的概念,这与iPhone本身无关。在地理系统中,需要考虑两个北参考:磁北极(根据地球磁场定义)和真北极(根据地球旋转轴定义)。

位置感知编程指南中也对此进行了详细解释(就像所有事情一样;始终阅读编程指南,这些指南通常都是很棒且非常完整的资源):

可以相对于地图上的磁北或真北来报告航向值。磁北代表地球表面上地球磁场的发出点。这个位置与代表正北的北极不同。根据设备的位置,磁北可能足以满足多种用途,但距离两极越近,该值的用处就越小。

This is called the "heading" of a CLLocation.

See the CLLocationManager doc part to configure heading for you app and call startUpdatingHeading to be notified with your heading changes, namely when your iPhone is pointing toward another point.

Then use the standard CLLocationManagerDelegate methods to be informed of heading changes and redraw your line accordingly.

Read the Location Awareness Programming Guide for more info about Location Services and heading, especially this part that even contains sample code.


PS: About the two different north, there is no concept of "iPhone North Pole", that's nothing related the the iPhone itself. In Geographic systems, there are two north references to consider: the Magnetic North Pole, which is defined according to the earth magnetic field, and the True North Pole, which is defined according the rotational axis of the earth.

That's also explained in details in the Location Awareness Programming Guide too (like quite everything; always read Programming Guides which are great and very complete resources in general):

Heading values can be reported relative either to magnetic north or true north on the map. Magnetic north represents the point on the Earth’s surface from which the planet’s magnetic field emanates. This location is not the same as the North Pole, which represents true north. Depending on the location of the device, magnetic north may be good enough for many purposes, but the closer to the poles you get, the less useful this value becomes.

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