开发者

iphone: ubercab aka (uber) map coordinate

Can anyone describe how to get the map coordinate of a MKMapView by its position on center of screen? Check out Uber app (its free). They have a pin statically located in the middle of the screen and you drag the map but the pin s开发者_运维技巧tays there. The middle of the screen is they find your location (very very quickly) showing you the address you are close to.


Heyo! I'm the mobile Engineer at Uber (you asked for some Uber help I assume :)) The trick is to place the pin, which is actually a UIImage, at the center of the map. The pin is on top of the map and is not an annotation. Then, whenever you get the regionDidChangeAnimated callback, you get the coordinate of the center of the map using this:

CLLocationCoordinate2D center = m_mapView.centerCoordinate;
CLLocation *location = [[[CLLocation alloc] initWithLatitude:center.latitude longitude:center.longitude] autorelease];

Ideally, you want the bottom part of the pin to point exactly at the center of the map view.

Hope this helps, Jordan

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜