Yes, I used Google to find out how to do. I found many ways like your link. Let's explain my problem.
MKMapView showsUserLocation is at TRUE.
So, when the view loads, I have my map with an annotation "Current location" in blue, but I can almost see the world on the map. So I need to center and zoom on the current location in blue. But it didn't work for me, it zooms in the middle of the ocean, when I tried:
- (void)viewDidLoad {
MKCoordinateRegion region;
region.center.latitude = googleMap.userLocation.coordinate.latitude;
region.center.longitude = googleMap.userLocation.coordinate.longitude;
region.span.latitudeDelta = 0.0039;
region.span.longitudeDelta = 0.0034;
googleMap.region = region;
}
googleMap is my MKMapView object. I can't get my userLocation coordinates right. That's why I'm in the middle of the ocean.
Then, I tried in my view which is MKMapViewDelegate:
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated {
MKCoordinateRegion region;
region.center.latitude = mapView.userLocation.coordinate.latitude;
region.center.longitude = mapView.userLocation.coordinate.longitude;
region.span.latitudeDelta = 0.0039;
region.span.longitudeDelta = 0.0034;
mapView.region = region;
}
It didn't work either, I'm in still in the middle of the ocean, somewhere...
So how can I get the right user location that I can zoom on the right location?
Thank you.