iphone: ubercab aka (uber) map coordinate

▼魔方 西西 提交于 2020-01-12 03:42:08

问题


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 stays there. The middle of the screen is they find your location (very very quickly) showing you the address you are close to.


回答1:


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



来源:https://stackoverflow.com/questions/5164141/iphone-ubercab-aka-uber-map-coordinate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!