我的要求是实现与 Hailo 应用类似的功能 https://appsto.re/us/ED46B.i
我最初可以将用户位置置于 map View 的中心
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKAnnotationView* annotationView = [mapView viewForAnnotation:userLocation];
mapViewNearby.centerCoordinate = userLocation.coordinate;
annotationView.canShowCallout = YES;
}
现在,我想做的是,如果用户缩放或遍历 map View ,我想找到新中心位置的坐标。然后启动反向地理编码。我已经实现了反向地理编码部分。目前,当用户拖动或缩放 map View 时,我正在努力寻找中心位置坐标。帮助高度赞赏
最佳答案
添加此 MKMapView 委托(delegate)方法。您可以使用 mapView.centerCoordinate 获取中心坐标。
-(void) mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
NSLog(@"%f %f",mapView.centerCoordinate.latitude,mapView.centerCoordinate.longitude);
}
关于ios - 如何获取mapview的中心位置坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28207738/