blob: f26a007c15697e853813ed3644cfe3abd463d7a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#import "MBXEmbeddedMapViewController.h"
#import <Mapbox/Mapbox.h>
typedef NS_ENUM(NSInteger, MBXEmbeddedControl) {
MBXEmbeddedControlZoom = 0,
MBXEmbeddedControlScroll,
MBXEmbeddedControlRotation,
MBXEmbeddedControlPitch
};
@interface MBXEmbeddedMapViewController () <UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet MGLMapView *mapView;
@end
@implementation MBXEmbeddedMapViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.scrollView.delegate = self;
self.scrollView.contentSize = self.view.bounds.size;
}
- (IBAction)didSwitch:(UISwitch *)controlSwitch {
[self switchControl:controlSwitch.tag];
}
- (IBAction)rotation:(UIRotationGestureRecognizer *)rotationGesture {
self.mapView.transform = CGAffineTransformRotate(rotationGesture.view.transform, rotationGesture.rotation);
}
- (void)switchControl:(MBXEmbeddedControl) control {
switch (control) {
case MBXEmbeddedControlZoom:
self.mapView.zoomEnabled = !self.mapView.zoomEnabled;
break;
case MBXEmbeddedControlScroll:
self.mapView.scrollEnabled = !self.mapView.scrollEnabled;
break;
case MBXEmbeddedControlRotation:
self.mapView.rotateEnabled = !self.mapView.rotateEnabled;
break;
case MBXEmbeddedControlPitch:
self.mapView.pitchEnabled = !self.mapView.pitchEnabled;
break;
}
}
- (BOOL)statusForControl:(MBXEmbeddedControl) control {
switch (control) {
case MBXEmbeddedControlZoom:
return self.mapView.zoomEnabled;
case MBXEmbeddedControlScroll:
return self.mapView.scrollEnabled;
case MBXEmbeddedControlRotation:
return self.mapView.rotateEnabled;
case MBXEmbeddedControlPitch:
return self.mapView.pitchEnabled;
}
}
#pragma mark UIScrollViewDelegate methods
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.mapView;
}
#pragma mark Class method
+ (NSString *)titleForControl:(MBXEmbeddedControl) control {
switch (control) {
case MBXEmbeddedControlZoom:
return @"Zoom Enabled";
case MBXEmbeddedControlScroll:
return @"Scroll Enabled";
break;
case MBXEmbeddedControlRotation:
return @"Rotation Enabled";
break;
case MBXEmbeddedControlPitch:
return @"Pitch Enabled";
break;
}
}
@end
|