summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--include/mbgl/ios/MGLMapView+IBAdditions.h6
-rw-r--r--include/mbgl/ios/MGLMapView.h8
-rw-r--r--platform/ios/MGLMapView.mm51
4 files changed, 35 insertions, 31 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6ffd58eeb..d8953f86dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## iOS master
+- The `styleID` property has been removed from MGLMapView. Instead, set the `styleURL` property to an NSURL in the form `mapbox://styles/STYLE_ID`. If you previously set the style ID in Interface Builder’s Attributes inspector, delete the `styleID` entry from the User Defined Runtime Attributes section of the Identity inspector, then set the new “Style URL” inspectable to a value in the form `mapbox://styles/STYLE_ID`. ([#2632](https://github.com/mapbox/mapbox-gl-native/pull/2632)
- The SDK now builds with Bitcode enabled. ([#2332](https://github.com/mapbox/mapbox-gl-native/issues/2332))
- The double-tap-drag gesture for zooming in and out is now consistent with the Google Maps SDK. ([#2153](https://github.com/mapbox/mapbox-gl-native/pull/2153))
- A new `MGLAnnotationImage.enabled` property allows you to disable touch events on individual annotations. ([#2501](https://github.com/mapbox/mapbox-gl-native/pull/2501))
diff --git a/include/mbgl/ios/MGLMapView+IBAdditions.h b/include/mbgl/ios/MGLMapView+IBAdditions.h
index 693457413f..ce50194993 100644
--- a/include/mbgl/ios/MGLMapView+IBAdditions.h
+++ b/include/mbgl/ios/MGLMapView+IBAdditions.h
@@ -11,7 +11,11 @@ NS_ASSUME_NONNULL_BEGIN
// inspectables declared in MGLMapView.h are always sorted before those in
// MGLMapView+IBAdditions.h, due to ASCII sort order.
-@property (nonatomic, nullable) IBInspectable NSString *styleID;
+// HACK: We want this property to look like a URL bar in the Attributes
+// inspector, but just calling it styleURL would violate Cocoa naming
+// conventions and conflict with the existing NSURL property. Fortunately, IB
+// strips out the two underscores for display.
+@property (nonatomic, nullable) IBInspectable NSString *styleURL__;
// Convenience properties related to the initial viewport. These properties
// are not meant to be used outside of Interface Builder. latitude and longitude
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index e7f8446907..4506d30fb6 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -227,13 +227,7 @@ IB_DESIGNABLE
/** @name Styling the Map */
-/** Mapbox ID of the style currently displayed in the receiver, or `nil` if the style does not have an ID.
-*
-* 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, nullable) NSString *styleID;
-@property (nonatomic, nullable) NSString *mapID __attribute__((unavailable("Use styleID.")));
+@property (nonatomic, nullable) NSString *styleID __attribute__((unavailable("Set styleURL to an NSURL of the form <mapbox://styles/STYLE_ID>, where STYLE_ID would have been the value of this property.")));
/** URLs of the styles bundled with the library. */
@property (nonatomic, readonly) NS_ARRAY_OF(NSURL *) *bundledStyleURLs;
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 5d35195c56..6977b1de24 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -192,7 +192,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleURL
{
- return [NSSet setWithObject:@"styleID"];
+ return [NSSet setWithObjects:@"styleURL__", nil];
}
- (nonnull NSURL *)styleURL
@@ -2012,37 +2012,21 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
return [NSArray arrayWithArray:_bundledStyleURLs];
}
-+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleID
-{
- return [NSSet setWithObject:@"styleURL"];
-}
-
- (nullable NSString *)styleID
{
- NSURL *styleURL = self.styleURL;
- return [styleURL.scheme isEqualToString:@"mapbox"] ? styleURL.host.mgl_stringOrNilIfEmpty : nil;
-}
-
-- (void)setStyleID:(nullable NSString *)styleID
-{
- self.styleURL = styleID ? [NSURL URLWithString:[NSString stringWithFormat:@"mapbox://%@", styleID]] : nil;
-}
-
-- (nullable NSString *)mapID
-{
[NSException raise:@"Method unavailable" format:
- @"%s has been renamed -[MGLMapView styleID].",
+ @"%s has been replaced by -[MGLMapView styleURL].",
__PRETTY_FUNCTION__];
return nil;
}
-- (void)setMapID:(nullable NSString *)mapID
+- (void)setStyleID:(nullable NSString *)styleID
{
[NSException raise:@"Method unavailable" format:
- @"%s has been renamed -[MGLMapView setStyleID:].\n\n"
- @"If 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.",
- __PRETTY_FUNCTION__, mapID];
+ @"%s has been replaced by -[MGLMapView setStyleURL:].\n\n"
+ @"If you previously set this style ID in a storyboard inspectable, select the MGLMapView in Interface Builder and delete the “styleID” entry from the User Defined Runtime Attributes section of the Identity inspector. "
+ @"Then go to the Attributes inspector and enter “mapbox://styles/%@” into the “Style URL” field.",
+ __PRETTY_FUNCTION__, styleID];
}
- (NS_ARRAY_OF(NSString *) *)styleClasses
@@ -3326,6 +3310,27 @@ class MBGLView : public mbgl::View
@implementation MGLMapView (IBAdditions)
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleURL__
+{
+ return [NSSet setWithObject:@"styleURL"];
+}
+
+- (nullable NSString *)styleURL__
+{
+ return self.styleURL.absoluteString;
+}
+
+- (void)setStyleURL__:(nullable NSString *)URLString
+{
+ NSURL *url = URLString.length ? [NSURL URLWithString:URLString] : nil;
+ if (URLString.length && !url)
+ {
+ [NSException raise:@"Invalid style URL" format:
+ @"“%@” is not a valid style URL.", URLString];
+ }
+ self.styleURL = url;
+}
+
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingLatitude
{
return [NSSet setWithObjects:@"centerCoordinate", @"camera", nil];