任何人都可以解释如何将MKMapPoint转换为CGPoint吗?我需要在UIView上使用纬度和经度绘制路径。
答案 0 :(得分:15)
接受的答案将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];
答案 1 :(得分:-3)
更新了答案.......
CGPoint newCenter = [self.mapView convertCoordinate:coordinates toPointToView:self.mapView];