diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-04-03 00:13:34 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-04-03 12:41:38 -0700 |
commit | d1fb43e37182e6364f6f0efa3c2644709893159a (patch) | |
tree | 8c8d1e11a84b2ef1ca92996bb8fa4c9c63704dfb | |
parent | 6eb79338f3298de8f0137125783f505f3cb9b407 (diff) | |
download | qtlocation-mapboxgl-d1fb43e37182e6364f6f0efa3c2644709893159a.tar.gz |
Inspectable toggles
Added inspectables for toggling zooming, panning, rotating, and showing the user location for parity with `MKMapView`.
-rw-r--r-- | include/mbgl/ios/MGLMapView+IBAdditions.h | 11 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 60 |
2 files changed, 70 insertions, 1 deletions
diff --git a/include/mbgl/ios/MGLMapView+IBAdditions.h b/include/mbgl/ios/MGLMapView+IBAdditions.h index fdd1ea3503..df9a19a6b7 100644 --- a/include/mbgl/ios/MGLMapView+IBAdditions.h +++ b/include/mbgl/ios/MGLMapView+IBAdditions.h @@ -11,7 +11,7 @@ @property (nonatomic) IBInspectable NSString *accessToken; @property (nonatomic) IBInspectable NSString *mapID; -// Some convenience properties related to the initial viewport. These properties +// Convenience properties related to the initial viewport. These properties // are not meant to be used outside of Interface Builder. latitude and longitude // are backed by properties of type CLLocationDegrees, but these declarations // must use the type double because Interface Builder is unaware that @@ -21,4 +21,13 @@ @property (nonatomic) IBInspectable double longitude; @property (nonatomic) IBInspectable double zoomLevel; +// Renamed properties. Interface Builder derives the display name of each +// inspectable from the runtime name, but runtime names don’t always make sense +// in UI. + +@property (nonatomic) IBInspectable BOOL allowsZooming; +@property (nonatomic) IBInspectable BOOL allowsScrolling; +@property (nonatomic) IBInspectable BOOL allowsRotating; +@property (nonatomic) IBInspectable BOOL showsUserLocation; + @end diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 18937b94fb..741f659ad4 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1064,6 +1064,21 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; #pragma mark - Properties - ++ (NSSet *)keyPathsForValuesAffectingZoomEnabled +{ + return [NSSet setWithObject:@"allowsZooming"]; +} + ++ (NSSet *)keyPathsForValuesAffectingScrollEnabled +{ + return [NSSet setWithObject:@"allowsScrolling"]; +} + ++ (NSSet *)keyPathsForValuesAffectingRotateEnabled +{ + return [NSSet setWithObject:@"allowsRotating"]; +} + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" @@ -2463,4 +2478,49 @@ class MBGLView : public mbgl::View } } ++ (NSSet *)keyPathsForValuesAffectingAllowsZooming +{ + return [NSSet setWithObject:@"zoomEnabled"]; +} + +- (BOOL)allowsZooming +{ + return self.zoomEnabled; +} + +- (void)setAllowsZooming:(BOOL)allowsZooming +{ + self.zoomEnabled = allowsZooming; +} + ++ (NSSet *)keyPathsForValuesAffectingAllowsScrolling +{ + return [NSSet setWithObject:@"scrollEnabled"]; +} + +- (BOOL)allowsScrolling +{ + return self.scrollEnabled; +} + +- (void)setAllowsScrolling:(BOOL)allowsScrolling +{ + self.scrollEnabled = allowsScrolling; +} + ++ (NSSet *)keyPathsForValuesAffectingAllowsRotating +{ + return [NSSet setWithObject:@"rotateEnabled"]; +} + +- (BOOL)allowsRotating +{ + return self.rotateEnabled; +} + +- (void)setAllowsRotating:(BOOL)allowsRotating +{ + self.rotateEnabled = allowsRotating; +} + @end |