ここで地域座標を設定しています:
// Center Map Here on initial load
#define CENTER_LATITUDE 22.11111 #fake for example
#define CENTER_LONGITUDE -23.99292 #fake for example
ここで領域ズームを設定しています:
MKCoordinateRegion region;
region.center.latitude = CENTER_LATITUDE;
region.center.longitude = CENTER_LONGITUDE;
region.span.latitudeDelta = SPAN_VALUE;
region.span.longitudeDelta = SPAN_VALUE;
[self.mapView setRegion:region animated:NO];
これが私の mapView didUpdateUserLocation メソッドです:
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation
*)userLocation {
CLLocationCoordinate2D loc = [userLocation coordinate];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 500, 500);
[self.mapView setRegion:region animated:YES];
self.mapView.centerCoordinate = userLocation.location.coordinate;
}
これは定義された領域にのみズームインすることを知っていますが、これに似たものを使用して、上記のような事前定義された座標ではなく、現在のユーザーの位置を取得する方法はありますか?
マップで現在のユーザーの場所を見つけて、それが理にかなっていれば、マップ上でズームする必要があります。