Sravan
Sravan

Reputation: 1941

how to convert MKMapPoint to CGPoint

Can any one explain how to convert MKMapPoint to CGPoint ? I need to draw path using latitude and longitude on a UIView.

Upvotes: 0

Views: 5526

Answers (2)

Dharmbir Singh
Dharmbir Singh

Reputation: 17535

Updated answer.......

CGPoint newCenter = [self.mapView convertCoordinate:coordinates toPointToView:self.mapView];

Upvotes: -2

pnizzle
pnizzle

Reputation: 6431

The accepted answer coverts CLLocationCoordinate2D to CGPoint, which is not what is asked in the actual question. For those looking for the full answer here it is:

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];

Upvotes: 16

Related Questions