Monday, 22 June 2015

Zoom Out the MapView for iOS

Add the Frameworks: MapKit, CoreLocation

Create a New File for MapViewController & Add the Below Code’s

MapViewController.h
#import <MapKit/MapKit.h>

@interface MapViewController : UIViewController <MKMapViewDelegate>

@property (weaknonatomicIBOutlet MKMapView *map_view;

@end


MapViewController.m
#import "MapViewController.h"

@interface MapViewController ()
@end

@implementation MapViewController

@synthesize map_view;

- (void)viewDidLoad
{
    [super viewDidLoad];
    map_view.delegate = self;
map_view.mapType = MKMapTypeStandard;

    [self zoom_out_view];
}

- (void)zoom_out_view
{
// step.1 create co-ordianate-span as follows
    MKCoordinateSpan span = {.latitudeDelta = 180, .longitudeDelta = 360};
    
    // step.2 crate region as follows
    MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0000f0.0000f), span);
    
    // step.3 zoom using region to map as follows
    [map_view setRegion:region animated:YES];

}

No comments: