【发布时间】:2013-04-04 13:53:28
【问题描述】:
谁能解释如何将 MKMapPoint 转换为 CGPoint ?我需要在 UIView 上使用纬度和经度绘制路径。
【问题讨论】:
谁能解释如何将 MKMapPoint 转换为 CGPoint ?我需要在 UIView 上使用纬度和经度绘制路径。
【问题讨论】:
更新答案.......
CGPoint newCenter = [self.mapView convertCoordinate:coordinates toPointToView:self.mapView];
【讨论】:
接受的答案将 CLLocationCoordinate2D 转换为 CGPoint,这不是实际问题中所问的。对于那些在这里寻找完整答案的人来说,它是:
MKMapPoint mapPoint = MKMapPointMake(22.1, 34.4);//example
//first convert MKMapPoint to CLLocationCoordinate2D
CLLocationCoordinate2D mapPointCoordinate = MKCoordinateForMapPoint(mapPoint);
//second convert CLLocationCoordinate2D to CGPoint
CGPoint pointAsCGPoint = [self.mapView convertCoordinate: mapPointCoordinate toPointToView: self.mapView];
【讨论】: