<

Map View

>

Setup:

  1. Create a Single View Application
  2. Drag the MapKitView object into your Storyboard
  3. Bring over a ToolBar object. Add three Bar Button Items

Make connections from the MapKitView to the .h file.
Make connections from the ToolBar item to the.h file.

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

@interface WebViewController : UIViewController
@property (strong, nonatomic) IBOutlet MKMapView *mapView;
- (IBAction)changeMapType:(id)sender;
- (IBAction)johnsHouse:(id)sender;
- (IBAction)alyciaHome:(id)sender;
- (IBAction)dylanButton:(id)sender;

@end

 


//
// WebViewController.m
// WhereDylanLives
//
// Created by John Valentino on 10/7/14.
// Copyright (c) 2014 SLU. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()

@end

@implementation WebViewController

@synthesize mapView;

-(void) goLocation

{

MKCoordinateRegion newRegion;
newRegion.center.latitude = 30.511;
newRegion.center.longitude = -90.468;
newRegion.span.latitudeDelta = 0.01;
newRegion.span.longitudeDelta = 0.01;

//30.511308, -90.468564


[self.mapView setRegion:newRegion animated:YES];
}
-(void) johnLocation

{

MKCoordinateRegion newRegion;
newRegion.center.latitude = 41.158;
newRegion.center.longitude = -74.012;
newRegion.span.latitudeDelta = 0.001;
newRegion.span.longitudeDelta = 0.001;

//41.158920, -74.012882



[self.mapView setRegion:newRegion animated:YES];
}
-(void) alyciaLocation

{

MKCoordinateRegion newRegion;
newRegion.center.latitude = 35.673;
newRegion.center.longitude = 139.78;
newRegion.span.latitudeDelta = 0.01;
newRegion.span.longitudeDelta = 0.01;

//35.673499, 139.781408
[self.mapView setRegion:newRegion animated:YES];
}

 

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self johnLocation];
mapView.showsUserLocation = NO;

}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

- (IBAction)changeMapType:(id)sender {
if (mapView.mapType == MKMapTypeStandard)
mapView.mapType = MKMapTypeSatellite;
else
mapView.mapType = MKMapTypeStandard;
}

- (IBAction)johnsHouse:(id)sender {
[self johnLocation];
mapView.showsUserLocation = YES;

}

- (IBAction)alyciaHome:(id)sender {
[self alyciaLocation];
mapView.showsUserLocation = YES;

}
@end