iphone: ubercab aka (uber) map coordinate

前端 未结 1 921
半阙折子戏
半阙折子戏 2021-02-06 13: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

相关标签:
1条回答
  • 2021-02-06 13:41

    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 讨论(0)
提交回复
热议问题