Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the center location coordinates of the mapview

My requirement is the implement similar functionality to Hailo app https://appsto.re/us/ED46B.i

I can centered the user location initially on the map view

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

}

Now, what I want to do is, If user zoom or traverse through the mapview I want to find coordinate of the new center location. And then initiate reverse geocoding. I have already implement the reverse geocoding part. Currently I am struggling to find the center location coordinates when the user drag or zoom the map view. Help highly appreciated

like image 880
smartsanja Avatar asked Jan 29 '15 05:01

smartsanja


1 Answers

Add this MKMapView delegate method. You can get the center coordiate with mapView.centerCoordinate.

-(void) mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
            NSLog(@"%f %f",mapView.centerCoordinate.latitude,mapView.centerCoordinate.longitude);
    }
like image 199
LiveBird Avatar answered Sep 26 '22 12:09

LiveBird