How to draw an infinite line at a specific degree angle (e.g. 270W) using Apple MapKit?

598 views Asked by At

I've read the docs on MKMapView and can't find any API for drawing fixed width lines at specific degree angles in the mapView's coordinate system (so my lines rotate when the user rotates the map (to stay in sync with the degree angle they represent)). This must be possible right? Any ideas?

UPDATE 1:

I've looked into MKPolyline and only see API for polylineWithPoints:count: and polylineWithCoordinates:count: but nothing for "line at degree angle" such as 270. I need the line to draw all the way around the globe through my current location. The compass app shows angles of degree and I need to represent an angle of degree in the mapView through my current location. What am I missing?

UPDATE 2:

In the following image you can see the TOP of the screen is 270° W and the RIGHT of the screen is 0° N. How do I draw a line that intersects my current location and extends in a straight line at 270° W as depicted in the image below? Desired Outcome as Screenshot

1

There are 1 answers

0
matt On BEST ANSWER

Since you are speaking in terms of an angle specified by degrees of a circle, it sounds like you want to do plane geometry.

The easiest way to do that on a map view is with MKMapPoints. Translate the coordinate of your starting point into a map point with MKMapPointForCoordinate; now pick another MKMapPoint at some distance away and at the angle you want; and connect them with an MKPolyline that you show as an overlay to the map.

Translating the notion "an angle of n degrees from my point and north" into a point on the line that runs away from your point at that angle is then a trivial matter of elementary plane trigonometry.