gpt4 book ai didi

ios - 基于指南针旋转 GMSMapView

转载 作者:行者123 更新时间:2023-12-01 18:43:56 26 4
gpt4 key购买 nike

我正在开发一个不允许手动与 map 交互的应用程序。更改 map 的唯一方法是当用户朝一个方向移动时。因此,如果用户旋转手机会旋转,因此基于 iPhone 中的指南针, map 应自动旋转,而不是用户通过 2 个手指手势将其旋转到方向。这是一张更清晰的想法的图片:
enter image description here
将红点视为我的位置,当我旋转手机时,我希望谷歌地图随之旋转。所以我的问题是如何实现这一目标?因为有一种方法我找到了[_myMap animateToViewingAngle:45];搜索后,但这并没有达到我想要的效果。
编辑 我想到了有什么办法可以将纬度和经度值转换为角度?

最佳答案

您可以使用 course来自 CLLocation 的属性(property)并将其传递给 animateToBearing你的方法GMSMapView .来自 the documentation :

Swift

var course: CLLocationDirection { get }

Objective-C

@property(readonly, nonatomic) CLLocationDirection course

Discussion

Course values are measured in degrees starting at due north and continuing clockwise around the compass. Thus, north is 0 degrees, east is 90 degrees, south is 180 degrees, and so on. Course values may not be available on all devices. A negative value indicates that the direction is invalid.

关于ios - 基于指南针旋转 GMSMapView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38369929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com