문제

Hello for a navigation based application i need to get CGPoint from coordinates OR MKMapPoint of a MKMapView. I want to draw a line between these points but not a poly line.

I know all about MKPolyLine and other custom polyLines but due to some specific condition i have to get CGPoint from coordinates OR MKMapPoint..

I know how to get coordinates from CGPoint

CLLocationCoordinate2D touchMapCoordinate 
    = [mapView convertPoint:touchPoint toCoordinateFromView:mapView];

But i want reverse also.... I know how to get MKMapPoint

MKMapPoint  mp = MKMapPointForCoordinate(aCoordinate);

but dont know how to convert MKMapPoint to CGPoint. Please help me.

도움이 되었습니까?

해결책

to convert co-ordinates to CGPoint, use below method

CGPoint point = [mapView convertCoordinate:location toPointToView:overlayView];

here location is CLLocationCoordinate2D object which has map latitude and longitude and overlayView is a view where you need to draw the polylines.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top