Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKMapView maptype not changing?

I cannot understand why my MKMapView does not want to change to satellite view. This method is called and case 1 is called I have stepped over it but it simply does not change to satellite type it always changes to standard. It only works when it goes back to Map type. Anyone have any ideas?

- (IBAction)mapSatelliteSegmentControlTapped:(UISegmentedControl *)sender
{
    switch (sender.selectedSegmentIndex)
    {
        case 1: //Satellite 
            self.mapView.mapType = MKMapTypeSatellite;
        default:  //Map 
            self.mapView.mapType = MKMapTypeStandard;
    }
}
like image 298
TheLearner Avatar asked Jan 12 '11 13:01

TheLearner


2 Answers

Your MKMapView is always ready to change to the satellite view. But you are forcing it to be in the standard view.

"You missed the break statement in case 1".

like image 62
EmptyStack Avatar answered Sep 20 '22 14:09

EmptyStack


switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
        case 0:
            map.mapType = MKMapTypeStandard;
            break;
        case 1:
            map.mapType = MKMapTypeSatellite;
            break;
        case 2:
            map.mapType = MKMapTypeHybrid;
            break;

        default:
            break;
    }

use this code and hookup at xib with "change the value" to segment controll

like image 28
user1099556 Avatar answered Sep 22 '22 14:09

user1099556