formatting & docs changes
Ran this through `./ios/docs/install_docs.sh` to double-check things. * Less-specific initializers above more-specific per Apple convention. * Shores up `accessToken` docs as property, not a method. * Edited comments for consistency and/or to keep them out of the docs.
This commit is contained in:
committed by
Minh Nguyễn
parent
836de8bc1c
commit
2916ae2735
@@ -17,13 +17,8 @@
|
||||
// must use the type double because Interface Builder is unaware that
|
||||
// CLLocationDegrees is a typedef for double.
|
||||
|
||||
/// Initial latitude at which the receiver is centered.
|
||||
@property (nonatomic) IBInspectable double latitude;
|
||||
|
||||
/// Initial longitude at which the receiver is centered.
|
||||
@property (nonatomic) IBInspectable double longitude;
|
||||
|
||||
/// Initial zoom level of the receiver.
|
||||
@property (nonatomic) IBInspectable double zoomLevel;
|
||||
|
||||
@end
|
||||
|
||||
@@ -20,19 +20,19 @@ IB_DESIGNABLE
|
||||
|
||||
/** @name Initializing a Map View */
|
||||
|
||||
/** Initialize a map view with a given frame, access token, and style URL.
|
||||
* @param frame The frame with which to initialize the map view.
|
||||
* @param accessToken A Mapbox API access token.
|
||||
* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`).
|
||||
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
|
||||
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL;
|
||||
|
||||
/** Initialize a map view with the default style given a frame and access token.
|
||||
/** Initialize a map view with the default style and a given frame and access token.
|
||||
* @param frame The frame with which to initialize the map view.
|
||||
* @param accessToken A Mapbox API access token.
|
||||
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
|
||||
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken;
|
||||
|
||||
/** Initialize a map view with a given frame, access token, and style URL.
|
||||
* @param frame The frame with which to initialize the map view.
|
||||
* @param accessToken A Mapbox API access token.
|
||||
* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`).
|
||||
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
|
||||
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL;
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("Instantiating an MGLMapView requires setting a style and/or an access token.")));
|
||||
|
||||
#pragma mark - Authorizing Access
|
||||
@@ -166,7 +166,7 @@ IB_DESIGNABLE
|
||||
|
||||
/** Mapbox map ID of the style currently displayed in the receiver, or `nil` if the style does not have a map ID.
|
||||
*
|
||||
* The style may lack a map ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases.
|
||||
* The style may lack a map ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases.
|
||||
*
|
||||
* To display the default style, set this property to `nil`. */
|
||||
@property (nonatomic) NSString *mapID;
|
||||
@@ -175,9 +175,8 @@ IB_DESIGNABLE
|
||||
- (NSArray *)bundledStyleURLs;
|
||||
|
||||
/** URL of the style currently displayed in the receiver.
|
||||
|
||||
The URL may be a full HTTP or HTTPS URL or a Mapbox URL indicating the style’s map ID (`mapbox://<user.style>`). To display the default style, set this property to `nil`.
|
||||
*/
|
||||
*
|
||||
* The URL may be a full HTTP or HTTPS URL or a Mapbox URL indicating the style’s map ID (`mapbox://<user.style>`). To display the default style, set this property to `nil`. */
|
||||
@property (nonatomic) NSURL *styleURL;
|
||||
|
||||
#pragma mark - Annotating the Map
|
||||
|
||||
@@ -91,7 +91,8 @@ static NSURL *MGLURLForBundledStyleNamed(NSString *styleName)
|
||||
|
||||
@end
|
||||
|
||||
@implementation MGLMapView {
|
||||
@implementation MGLMapView
|
||||
{
|
||||
BOOL _isTargetingInterfaceBuilder;
|
||||
CLLocationDegrees _pendingLatitude;
|
||||
CLLocationDegrees _pendingLongitude;
|
||||
@@ -168,7 +169,8 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
|
||||
[MGLMapboxEvents setToken:accessToken.mgl_stringOrNilIfEmpty];
|
||||
}
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingStyleURL {
|
||||
+ (NSSet *)keyPathsForValuesAffectingStyleURL
|
||||
{
|
||||
return [NSSet setWithObjects:@"mapID", @"accessToken", nil];
|
||||
}
|
||||
|
||||
@@ -180,10 +182,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
|
||||
|
||||
- (void)setStyleURL:(NSURL *)styleURL
|
||||
{
|
||||
if ( _isTargetingInterfaceBuilder )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_isTargetingInterfaceBuilder) return;
|
||||
|
||||
if ( ! styleURL)
|
||||
{
|
||||
@@ -245,7 +244,8 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
|
||||
|
||||
// load extensions
|
||||
//
|
||||
dispatch_once(&loadGLExtensions, ^{
|
||||
dispatch_once(&loadGLExtensions, ^
|
||||
{
|
||||
const std::string extensions = (char *)glGetString(GL_EXTENSIONS);
|
||||
|
||||
using namespace mbgl;
|
||||
@@ -1319,16 +1319,19 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
|
||||
return [NSArray arrayWithArray:_bundledStyleURLs];
|
||||
}
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingMapID {
|
||||
+ (NSSet *)keyPathsForValuesAffectingMapID
|
||||
{
|
||||
return [NSSet setWithObjects:@"styleURL", @"accessToken", nil];
|
||||
}
|
||||
|
||||
- (NSString *)mapID {
|
||||
- (NSString *)mapID
|
||||
{
|
||||
NSURL *styleURL = self.styleURL;
|
||||
return [styleURL.scheme isEqualToString:@"mapbox"] ? styleURL.host.mgl_stringOrNilIfEmpty : nil;
|
||||
}
|
||||
|
||||
- (void)setMapID:(NSString *)mapID {
|
||||
- (void)setMapID:(NSString *)mapID
|
||||
{
|
||||
self.styleURL = [NSURL URLWithString:[NSString stringWithFormat:@"mapbox://%@", mapID]];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
@interface NSString (MGLAdditions)
|
||||
|
||||
/// Returns the receiver if non-empty or \c nil if empty.
|
||||
/** Returns the receiver if non-empty or nil if empty. */
|
||||
- (NSString *)mgl_stringOrNilIfEmpty;
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user