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.
谁能描述一下如何通过MKMapView在屏幕中心的位置来获得它的映射坐标吗?看看优步应用(它是免费的)。它们在屏幕中间有一个静态的大头针你拖拽地图但是大头针仍然在那里。屏幕的中间是他们找到你的位置(非常快地)显示你的地址。
1 个解决方案
#1
14
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:
Heyo !我是Uber的移动工程师(我猜你需要Uber的帮助),诀窍是把大头针(实际上是一个UIImage)放在地图的中心。大头针位于地图的顶部,不是注释。然后,每当你得到regionDidChangeAnimated callback,你会得到地图中心的坐标,用这个:
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.
理想情况下,您希望pin的底部部分准确地指向地图视图的中心。
Hope this helps, Jordan
希望这有助于,约旦
#1
14
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:
Heyo !我是Uber的移动工程师(我猜你需要Uber的帮助),诀窍是把大头针(实际上是一个UIImage)放在地图的中心。大头针位于地图的顶部,不是注释。然后,每当你得到regionDidChangeAnimated callback,你会得到地图中心的坐标,用这个:
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.
理想情况下,您希望pin的底部部分准确地指向地图视图的中心。
Hope this helps, Jordan
希望这有助于,约旦