将CLLocation或CLLocationCoordinate2D转换为CGPoint

时间:2013-06-21 11:44:24

标签: iphone ios cllocation cgpoint

如何将CLLocationCLLocationCoordinate2D转换为CGPoint。 我见过

CGPoint point = [mapView convertCoordinate:myCoordinates toPointToView:self.view];

但我不需要在我的情况下使用mapView。我尝试使用谷歌搜索,但没有任何帮助。

编辑: 我需要将地理坐标转换为iPad的屏幕坐标,如Convert decimal latitude/longitude coordinates to iPad screen coordinates中所示。 我试图根据转换的坐标值绘制线/路径。

有没有直接的方法,或者我需要编写算法来做同样的事情。

1 个答案:

答案 0 :(得分:9)

CGPoint myPoint = CGPointMake(coordinate.longitude, coordinate.latitude);

请注意,轴是交换的。但除非你给出一个你想要转换坐标的坐标系,否则你的问题没有意义。