views:

28

answers:

1

Hi all,

I am implement an application based on the MapKit using iphone sdk.I just now a method to get the event when we drag, zoom in/out on the map. The method is as like this

  • (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated

Now I need to get the following bullets.

1.TopLeft's and Bottom Right's Latitude and longitude values. 2.Center of the Map. 3.zoom level.

Please give me suggessions to solve the above 3 use cases.

Thanks in Advance, Sekhar Bethalam.

A: 

Hi all,

By using the following code I got the answer to get the values of center,topleft and bottom right latitude and longitude values of the map view. I need to get a solution for the answer question as well (i.e zoo level of the mapview). If you guys have any idea to get the zoom level please post me. Thanks in advance.

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{

       double centerLatitude= mapView.centerCoordinate.latitude;
       double centerLongitude= mapView.centerCoordinate.longitude;

       double topLeft Latitude= (mapView.centerCoordinate.latitude)+(mapView.region.span.latitudeDelta)/2;

       double topLeft Longitude= (mapView.centerCoordinate.latitude)-(mapView.region.span.longitudedeDelta)/2;


       double bottom Right Latitude= (mapView.centerCoordinate.latitude)-(mapView.region.span.latitudeDelta)/2;

       double bottom Right Longitude= (mapView.centerCoordinate.latitude)+(mapView.region.span.longitudedeDelta)/2;


}
sekhar