【问题标题】:How to get the center location coordinates of the mapview如何获取地图视图的中心位置坐标
【发布时间】:2015-03-28 06:24:32
【问题描述】:

我的要求是实现与 Hailo 应用 https://appsto.re/us/ED46B.i 类似的功能

我最初可以在地图视图上将用户位置居中

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    MKAnnotationView* annotationView = [mapView viewForAnnotation:userLocation];
    mapViewNearby.centerCoordinate = userLocation.coordinate;
    annotationView.canShowCallout = YES;

}

现在,我想做的是,如果用户缩放或遍历地图视图,我想找到新中心位置的坐标。然后启动反向地理编码。我已经实现了反向地理编码部分。目前,当用户拖动或缩放地图视图时,我正在努力寻找中心位置坐标。帮助高度赞赏

【问题讨论】:

标签: ios objective-c mkmapview core-location


【解决方案1】:
【解决方案2】:

添加此 MKMapView 委托方法。您可以使用 mapView.centerCoordinate 获取中心坐标。

-(void) mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
            NSLog(@"%f %f",mapView.centerCoordinate.latitude,mapView.centerCoordinate.longitude);
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 1970-01-01
    • 1970-01-01
    • 2015-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多