Getting position of the annotation relative to screen
I'd like to acquire the position (not map coordinates) of the annotation relative to the screen.
For example, for an annotation on the map, I'd like to know how far that particular pin is from the top left corner (0,0).
I've looked at the documentations开发者_运维问答, and it does not provide information on its absolute or relative location.
I'll look further into the quartz framework before possibly sub-classing and overriding the rendering methods as a last resort.
Any ideas?
Given an MKAnnotation, you can get the MKAnnocationView using [MKMapView viewForAnnoation]
. You can use that to the get the center of the view in window coordinates:
CGPoint windowPoint = [annView convertPoint:[annView center] toView:window]
The main UIWindow is generally available through your AppDelegate.
精彩评论