开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜