Merge pull request #1561 from 1ec5-style-id-1500

mapID → styleID
This commit is contained in:
Minh Nguyễn
2015-05-21 15:28:27 -07:00
3 changed files with 21 additions and 16 deletions

View File

@@ -8,7 +8,7 @@
// inspectables declared in MGLMapView.h are always sorted before those in
// MGLMapView+IBAdditions.h, due to ASCII sort order.
@property (nonatomic) IBInspectable NSString *mapID;
@property (nonatomic) IBInspectable NSString *styleID;
// Convenience properties related to the initial viewport. These properties
// are not meant to be used outside of Interface Builder. latitude and longitude

View File

@@ -157,12 +157,13 @@ IB_DESIGNABLE
/** @name Styling the Map */
/** Mapbox map ID of the style currently displayed in the receiver, or `nil` if the style does not have a map ID.
/** Mapbox ID of the style currently displayed in the receiver, or `nil` if the style does not have an 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 an 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;
@property (nonatomic) NSString *styleID;
@property (nonatomic) NSString *mapID __attribute__((unavailable("Use styleID.")));
/** Returns the URLs to the styles bundled with the library. */
- (NSArray *)bundledStyleURLs;

View File

@@ -153,7 +153,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
+ (NSSet *)keyPathsForValuesAffectingStyleURL
{
return [NSSet setWithObjects:@"mapID", nil];
return [NSSet setWithObject:@"styleID"];
}
- (NSURL *)styleURL
@@ -1556,27 +1556,31 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
return [NSArray arrayWithArray:_bundledStyleURLs];
}
+ (NSSet *)keyPathsForValuesAffectingMapID
+ (NSSet *)keyPathsForValuesAffectingStyleID
{
return [NSSet setWithObjects:@"styleURL", nil];
return [NSSet setWithObject:@"styleURL"];
}
- (NSString *)mapID
- (NSString *)styleID
{
NSURL *styleURL = self.styleURL;
return [styleURL.scheme isEqualToString:@"mapbox"] ? styleURL.host.mgl_stringOrNilIfEmpty : nil;
}
- (void)setStyleID:(NSString *)styleID
{
self.styleURL = styleID ? [NSURL URLWithString:[NSString stringWithFormat:@"mapbox://%@", styleID]] : nil;
}
- (NSString *)mapID
{
NSAssert(NO, @"-[MGLMapView mapID] has been renamed -[MGLMapView styleID].");
return nil;
}
- (void)setMapID:(NSString *)mapID
{
if (mapID)
{
self.styleURL = [NSURL URLWithString:[NSString stringWithFormat:@"mapbox://%@", mapID]];
}
else
{
self.styleURL = nil;
}
NSAssert(NO, @"-[MGLMapView setMapID:] has been renamed -[MGLMapView setStyleID:].\n\nIf you previously set this map ID in a storyboard inspectable, select the MGLMapView in Interface Builder and delete the “mapID” entry from the User Defined Runtime Attributes section of the Identity inspector. Then go to the Attributes inspector and enter “%@” into the “Style ID” field.", mapID);
}
- (NSArray *)styleClasses