Reputation: 863
Another possible way to resolve this is to know the distance from the center of the map (the PIN indicating the current user location) to the edge of the map view... If we have this information along with the azimuth (really an angle), we can calculate a second point and join the two points with a line or arrow using MKPolyline
.
Eventually, when the user zooms in/out of the map, the new point should be recalculated based on new distance.
So new question: with a given zoom level, can you get the distance between the center of the map on the screen and the edge of the map view?
I have found several answers on how to draw lines between two pins in map kit but what I am trying to accomplish is to draw an arrow or line from a PIN that indicates the user current location to the border of the screen. The line or arrow will be pointing to an azimuth that I'll provide. For example if the input azimuth is 0, the line/arrow will be pointing north. Also, it would be great if the line or arrow is redrawn when the user zooms out.
I don't expect a full answer (unless you have it of course) and I appreciate it if you can tell me where to start looking.
Please remember this is not about drawing a route or a line between two points...
Upvotes: 0
Views: 1146
Reputation: 863
This was answered VERY accurately by user Anna Karenina in another question I posted (MKMapPoint with MKMapPointMake from MKMapRect).
I posted the other question as I was breaking up the solution to this problem so the other question was meant to resolve part of the problem. However Anna expanded her answer to also also answer this question!
Regarding zooming in and out, one can simply redo the calculations that Anna mentioned in her answer at the link.
Upvotes: 0