Convert CLLocation or CLLocationCoordinate2D to CGPoint

Xavi Valero picture Xavi Valero · Jun 21, 2013 · Viewed 7.9k times · Source

How can I convert CLLocation or CLLocationCoordinate2D to CGPoint. I have seen

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

But I don't need to use mapView in my case. I tried googling, but didn't come across anything helpful.

Edit: I need to convert the geographic coordinates to iPad's screen coordinate as in Convert decimal latitude/longitude coordinates to iPad screen coordinates. I am trying to draw line/path based on the converted coordinate values.

Is there a direct way to do it, or do I need to write an algorithm to do the same.

Answer

nevan king picture nevan king · Jun 21, 2013
CGPoint myPoint = CGPointMake(coordinate.longitude, coordinate.latitude);

Note that the axes are swapped. But unless you give a coordinate system that you want the coordinate converted to, your question doesn't make sense.