【发布时间】:2023-03-31 03:44:02
【问题描述】:
如何将CLLocation 或CLLocationCoordinate2D 转换为CGPoint。
我见过
CGPoint point = [mapView convertCoordinate:myCoordinates toPointToView:self.view];
但在我的情况下,我不需要使用 mapView。我尝试了谷歌搜索,但没有发现任何有用的信息。
编辑: 我需要将地理坐标转换为 iPad 的屏幕坐标,如Convert decimal latitude/longitude coordinates to iPad screen coordinates。 我正在尝试根据转换后的坐标值绘制线/路径。
有没有直接的方法,或者我需要写一个算法来做同样的事情。
【问题讨论】:
-
如果你不需要使用mapView那你为什么需要将坐标转换为CGPoint呢?
-
除了使用地图视图之外别无他法。
-
我从
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations获得当前坐标。需要根据视图绘制路径。这里没有地图。 -
我不确定,没有 MapView 是否可以得到它..? .但我会给出一些想法,但这应该是 STUPID idea - 加载 Mapview 并隐藏它并使用您提到的方法获取 CGPoint ...
标签: iphone ios cllocation cgpoint