1

I would like the user to be able to change the map type on the map either by curling the right corner like Apple maps or a button on the map. Any ideas?

- (void)setUpMap {
//setMap

MKMapView *mapView = [[MKMapView alloc] initWithFrame:CGRectMake(10, 14, (self.bounds.size.width - (10 * 2)), (self.bounds.size.height - (10 * 2)))];

mapView.layer.borderColor = kITBarTint.CGColor;
mapView.layer.borderWidth = 1.0;
mapView.layer.cornerRadius = 15.0;
mapView.layer.shadowColor = [UIColor blackColor].CGColor;
mapView.layer.shadowOffset = CGSizeMake(5, 5);
mapView.layer.shadowRadius = 10;
mapView.mapType = MKMapTypeHybrid;

[mapView setDelegate:self];
[mapView setShowsUserLocation:NO];

[self addSubview:mapView];


NSMutableArray *locations = [NSMutableArray array];
BOOL isFirst = YES;
for (ITLocation *location in self.spider.locations) {
    ITObjectMark *mark = [[ITObjectMark alloc] initWithCoordinate:[location geopoint] addressDictionary:nil];
    mark.Object = self.Object;
    [locations addObject:mark];
    if (isFirst) {

        int zoomLevel = 2;

        // use the zoom level to compute the region
        [mapView setCenterCoordinate:[location geopoint] zoomLevel:zoomLevel animated:YES];
        isFirst = NO;
    }
}

[mapView addAnnotations:locations];

}
Steve
  • 151
  • 2
  • 12

1 Answers1

5

You can use an UISegmentedControler for that and set the map type. But for curling you need an new view controller where you place your buttons and presenting it with presentmodalviewcontroller style modal transition partial curl...

- (IBAction)setMap:(id)sender {

    switch (((UISegmentedControl *)sender).selectedSegmentIndex) {

        case 0:
        {
            mapView.mapType = MKMapTypeStandard;
            break;
        }

        case 1:
        {
            mapView.mapType = MKMapTypeSatellite;
            break;
        }

        case 2:
        {
            mapView.mapType = MKMapTypeHybrid;
            break;
        }
    }
}

But for curling you need an new view controller where you place your buttons and presenting it with presentmodalviewcontroller style modal transition partial curl... //Example

- (IBAction)goToSecond:(id)sender
 { 
    InfoController *ainfoController = [[InfoController alloc] 
                                       initWithNibName:@"InfoController" bundle:nil];
    ainfoController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    [self presentModalViewController:ainfoController animated:YES];
 }

To get changes use delegates... Delegate example

Community
  • 1
  • 1
Imodeveloper
  • 394
  • 4
  • 13