Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Make scale bar private
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Apr 4, 2017
1 parent 46d2a5a commit 7de5c27
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
## master

* The error passed into `-[MGLMapViewDelegate mapViewDidFailLoadingMap:withError:]` now includes a more specific description and failure reason. ([#8418](https://github.com/mapbox/mapbox-gl-native/pull/8418))
* Added a scale bar to MGLMapView that indicates the scale of the map. ([#7631](https://github.com/mapbox/mapbox-gl-native/pull/7631))

## 3.5.0

Expand Down
10 changes: 0 additions & 10 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
3557F7B21E1D27D300CCA5E6 /* MGLDistanceFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3557F7AF1E1D27D300CCA5E6 /* MGLDistanceFormatter.m */; };
35599DED1D46F14E0048254D /* MGLStyleValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35599DEA1D46F14E0048254D /* MGLStyleValue.mm */; };
35599DEE1D46F14E0048254D /* MGLStyleValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35599DEA1D46F14E0048254D /* MGLStyleValue.mm */; };
355ADFFD1E9281DA00F3939D /* MGLScaleBarView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 355ADFFA1E9281DA00F3939D /* MGLScaleBarView_Private.h */; };
355ADFFE1E9281DA00F3939D /* MGLScaleBarView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 355ADFFA1E9281DA00F3939D /* MGLScaleBarView_Private.h */; };
355ADFFF1E9281DA00F3939D /* MGLScaleBarView.h in Headers */ = {isa = PBXBuildFile; fileRef = 355ADFFB1E9281DA00F3939D /* MGLScaleBarView.h */; settings = {ATTRIBUTES = (Public, ); }; };
355AE0001E9281DA00F3939D /* MGLScaleBarView.h in Headers */ = {isa = PBXBuildFile; fileRef = 355ADFFB1E9281DA00F3939D /* MGLScaleBarView.h */; settings = {ATTRIBUTES = (Public, ); }; };
355AE0011E9281DA00F3939D /* MGLScaleBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 355ADFFC1E9281DA00F3939D /* MGLScaleBarView.m */; };
355AE0021E9281DA00F3939D /* MGLScaleBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 355ADFFC1E9281DA00F3939D /* MGLScaleBarView.m */; };
3566C7661D4A77BA008152BC /* MGLShapeSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 3566C7641D4A77BA008152BC /* MGLShapeSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -582,7 +578,6 @@
3557F7AE1E1D27D300CCA5E6 /* MGLDistanceFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLDistanceFormatter.h; sourceTree = "<group>"; };
3557F7AF1E1D27D300CCA5E6 /* MGLDistanceFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLDistanceFormatter.m; sourceTree = "<group>"; };
35599DEA1D46F14E0048254D /* MGLStyleValue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLStyleValue.mm; sourceTree = "<group>"; };
355ADFFA1E9281DA00F3939D /* MGLScaleBarView_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLScaleBarView_Private.h; sourceTree = "<group>"; };
355ADFFB1E9281DA00F3939D /* MGLScaleBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLScaleBarView.h; sourceTree = "<group>"; };
355ADFFC1E9281DA00F3939D /* MGLScaleBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLScaleBarView.m; sourceTree = "<group>"; };
3566C7641D4A77BA008152BC /* MGLShapeSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLShapeSource.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1041,7 +1036,6 @@
355ADFF91E9281C300F3939D /* Views */ = {
isa = PBXGroup;
children = (
355ADFFA1E9281DA00F3939D /* MGLScaleBarView_Private.h */,
355ADFFB1E9281DA00F3939D /* MGLScaleBarView.h */,
355ADFFC1E9281DA00F3939D /* MGLScaleBarView.m */,
);
Expand Down Expand Up @@ -1602,7 +1596,6 @@
350098DC1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.h in Headers */,
DA8848231CBAFA6200AB86E3 /* MGLOfflineStorage_Private.h in Headers */,
404326891D5B9B27007111BD /* MGLAnnotationContainerView_Private.h in Headers */,
355ADFFF1E9281DA00F3939D /* MGLScaleBarView.h in Headers */,
DA88483B1CBAFB8500AB86E3 /* MGLCalloutView.h in Headers */,
35E0CFE61D3E501500188327 /* MGLStyle_Private.h in Headers */,
3510FFF01D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */,
Expand Down Expand Up @@ -1631,7 +1624,6 @@
DD0902AB1DB192A800C5BDCE /* MGLNetworkConfiguration.h in Headers */,
DA8848571CBAFB9800AB86E3 /* MGLMapboxEvents.h in Headers */,
DA8848311CBAFA6200AB86E3 /* NSString+MGLAdditions.h in Headers */,
355ADFFD1E9281DA00F3939D /* MGLScaleBarView_Private.h in Headers */,
353933F81D3FB79F003F57D7 /* MGLLineStyleLayer.h in Headers */,
DAAF722D1DA903C700312FA4 /* MGLStyleValue_Private.h in Headers */,
DA8847F41CBAFA5100AB86E3 /* MGLOfflinePack.h in Headers */,
Expand Down Expand Up @@ -1750,12 +1742,10 @@
353933F31D3FB753003F57D7 /* MGLCircleStyleLayer.h in Headers */,
558DE7A11E5615E400C7916D /* MGLFoundation_Private.h in Headers */,
3538AA1E1D542239008EC33D /* MGLForegroundStyleLayer.h in Headers */,
355AE0001E9281DA00F3939D /* MGLScaleBarView.h in Headers */,
30E578181DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */,
40F887711D7A1E59008ECB67 /* MGLShapeSource_Private.h in Headers */,
DABFB8631CBE99E500D62B32 /* MGLOfflineRegion.h in Headers */,
DA35A2B21CCA141D00E826B2 /* MGLCompassDirectionFormatter.h in Headers */,
355ADFFE1E9281DA00F3939D /* MGLScaleBarView_Private.h in Headers */,
DAF0D8141DFE0EC500B28378 /* MGLVectorSource_Private.h in Headers */,
DABFB8731CBE9A9900D62B32 /* Mapbox.h in Headers */,
357FE2DE1E02D2B20068B753 /* NSCoder+MGLAdditions.h in Headers */,
Expand Down
17 changes: 9 additions & 8 deletions platform/ios/src/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ IB_DESIGNABLE
*/
- (IBAction)reloadStyle:(id)sender;

/**
A control indicating the scale of the map.
The scale bar becomes visible when a user interacts with the
map and fades out when the interaction stops. It’s positioned
in the upper-left corner.
*/
@property (nonatomic, readonly) UIView *scaleBarView;

/**
A control indicating the map’s direction and allowing the user to manipulate
the direction, positioned in the upper-right corner.
Expand Down Expand Up @@ -594,14 +603,6 @@ IB_DESIGNABLE
*/
@property (nonatomic) CLLocationDirection direction;

/**
Indicates whether the scale bar should become visible when a user interacts with
the map. The scale bar will fade out automatically when the interaction stops.
The default value for this property is `YES`.
*/
@property (nonatomic) BOOL showsScale;

/**
Changes the heading of the map and optionally animates the change.
Expand Down
9 changes: 4 additions & 5 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#import "MGLUserLocation_Private.h"
#import "MGLAnnotationImage_Private.h"
#import "MGLAnnotationView_Private.h"
#import "MGLScaleBarView_Private.h"
#import "MGLScaleBarView.h"
#import "MGLStyle_Private.h"
#import "MGLStyleLayer_Private.h"
#import "MGLMapboxEvents.h"
Expand Down Expand Up @@ -506,7 +506,6 @@ - (void)commonInit
_scaleBarView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_scaleBarView];
_scaleControlViewConstraints = [NSMutableArray array];
_showsScale = YES;

// setup interaction
//
Expand Down Expand Up @@ -4806,8 +4805,8 @@ - (void)cameraIsChanging {

[self updateCompass];

if (self.showsScale) {
self.scaleBarView.metersPerPoint = [self metersPerPointAtLatitude:self.centerCoordinate.latitude];
if (!self.scaleBarView.hidden) {
[(MGLScaleBarView *)self.scaleBarView setMetersPerPoint:[self metersPerPointAtLatitude:self.centerCoordinate.latitude]];
}

if ([self.delegate respondsToSelector:@selector(mapViewRegionIsChanging:)])
Expand Down Expand Up @@ -5200,7 +5199,7 @@ - (CGPoint)userLocationAnnotationViewCenter

- (void)notifyScaleBarGestureDidEnd
{
[self.scaleBarView fadeOut];
[(MGLScaleBarView *)self.scaleBarView fadeOut];
}

- (void)updateCompass
Expand Down
5 changes: 5 additions & 0 deletions platform/ios/src/MGLScaleBarView.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

@interface MGLScaleBarView : UIView

@property (nonatomic, assign) CLLocationDistance metersPerPoint;

- (void)fadeOut;

@end
3 changes: 1 addition & 2 deletions platform/ios/src/MGLScaleBarView.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#import <Mapbox/Mapbox.h>
#import "MGLScaleBarView.h"

#import "MGLScaleBarView_Private.h"

@class MGLScaleBarLabel;

@interface MGLScaleBarView()
@property (nonatomic, assign, getter=isVisible) BOOL visible;
@property (nonatomic, assign) CLLocationDistance metersPerPoint;
@property (nonatomic) NSArray<MGLScaleBarLabel *> *labels;
@property (nonatomic) NSArray<UIView *> *bars;
@property (nonatomic) UIView *containerView;
Expand Down
12 changes: 0 additions & 12 deletions platform/ios/src/MGLScaleBarView_Private.h

This file was deleted.

0 comments on commit 7de5c27

Please sign in to comment.