Changing Map Views


#1

In Order to enable Changing map type, first add items to the XIB:
“toolbar” —> inside toolbar which is usually placed on the bottom add “Segmented Control” buttons.
configure the segment control buttons to have three buttons and name them somewhat similar: map, satellite, hybrid. (adjust how you want them)

now in WhereAmIcontroller.h add these items:
{ "inside the brackets as an member item"
IBOutlet UISegmentedControl *switchMapType;
}

@property (nonatomic, retain) IBOutlet MKMapView *worldView;

  • (IBAction)setMap:(id)sender;

and now on the WhereAmIController.m add these items:
-(IBAction)setMap:(id)sender {
switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
case 0:
worldView.mapType = MKMapTypeStandard;
break;
case 1:
worldView.mapType = MKMapTypeSatellite;
break;

    case 2:
        worldView.mapType = MKMapTypeHybrid;
        break;
    default:
        break;
        
}

}


then go back to the XIB and connect these items:

Received Actions - setMap --------> (Segment Control “Value Changed”)

that should be it…