0

谁能解释如何将 MKMapPoint 转换为 CGPoint ?我需要在 UIView 上使用纬度和经度绘制路径。

4

2 回答 2

16

接受的答案将 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];
于 2014-07-23T01:33:29.853 回答
-2

更新答案.......

CGPoint newCenter = [self.mapView convertCoordinate:coordinates toPointToView:self.mapView];
于 2013-04-12T06:31:21.400 回答