Hi all,
I am implementing a MapKit based application. In that I need to set the zoom level as 15. Based on this I need to change the region. I tried with the following code but it is not working as expected. When I used the returned region and set to the Mapview it is getting exception like "NSInvalidArgumentException', reason: 'Invalid Region '".Can you guys suggest perfect way to solve this problem?
-(MKCoordinateRegion)getRegoinBasedOntheZoomLevel:(int)zoom
{
MKCoordinateRegion region;
MKCoordinateSpan span;
if (coords1.latitude != 0 && coords1.longitude !=0)
{
region.center = coords1;
}
else
{
region.center=mainMapView.region.center;
}
span.latitudeDelta=mainMapView.region.span.latitudeDelta *2*zoom;
span.longitudeDelta=mainMapView.region.span.longitudeDelta *2*zoom;
region.span=span;
return region;
}
Thanks in advance. Sekhar Bethalam.