iOS:定位我的地图的最佳方式View在左上角显示坐标



下面的代码将我的mapView定位在显示中心坐标的位置。但是,我需要它来定位mapView,它将在左上角显示我的坐标。下面的代码是我目前正在使用的代码。我正在使用名为MKMapView+ZoomLevel.h的类别。如果你需要更多信息,请告诉我。

[self.mapView setCenterCoordinate:coordinate zoomLevel:level animated:animated];

使用self.mapView.region获取区域,并使用一些简单的几何体找到新的坐标。区域将以经纬度为单位提供视图的中心点、宽度和高度。

从那里,您可以确定提供给地图视图的中心坐标,该坐标将在左上角设置您的原始坐标。

CLLocationCoordinate2DMake(self.mapView.coordinate.latitude +
    self.mapView.region.span.latitudeDelta / 2,
    self.mapView.coordinate.longitude +
    self.mapView.region.span.longitudeDelta / 2)

最新更新