summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/src/MGLMapView.h9
-rw-r--r--platform/ios/src/MGLMapView.mm15
2 files changed, 15 insertions, 9 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index 771a48c7ff..62f053e96b 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -123,6 +123,13 @@ IB_DESIGNABLE
Unlike the `styleURL` property, this property is set to an object that allows
you to manipulate every aspect of the style locally.
+ If the style is loading, this property is set to `nil` until the style finishes
+ loading. If the style has failed to load, this property is set to `nil`.
+ Because the style loads asynchronously, you should manipulate it in the
+ `-[MGLMapViewDelegate mapView:didFinishLoadingStyle:]` or
+ `-[MGLMapViewDelegate mapViewDidFinishLoadingMap:]` method. It is not possible
+ to manipulate the style before it has finished loading.
+
@note The default styles provided by Mapbox contain sources and layers with
identifiers that will change over time. Applications that use APIs that
manipulate a style's sources and layers must first set the style URL to an
@@ -130,7 +137,7 @@ IB_DESIGNABLE
`+[MGLStyle outdoorsStyleURLWithVersion:]`, `MGLMapView`'s “Style URL”
inspectable in Interface Builder, or a manually constructed `NSURL`.
*/
-@property (nonatomic, readonly) MGLStyle *style;
+@property (nonatomic, readonly, nullable) MGLStyle *style;
/**
URLs of the styles bundled with the library.
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index ddb11ffbb7..f8ca673093 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -347,6 +347,11 @@ public:
return self;
}
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyle
+{
+ return [NSSet setWithObject:@"styleURL"];
+}
+
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleURL
{
return [NSSet setWithObjects:@"styleURL__", nil];
@@ -369,10 +374,8 @@ public:
}
styleURL = styleURL.mgl_URLByStandardizingScheme;
- [self willChangeValueForKey:@"style"];
- _style = [[MGLStyle alloc] initWithMapView:self];
+ self.style = nil;
_mbglMap->setStyleURL([[styleURL absoluteString] UTF8String]);
- [self didChangeValueForKey:@"style"];
}
- (IBAction)reloadStyle:(__unused id)sender {
@@ -4682,11 +4685,7 @@ public:
}
case mbgl::MapChangeDidFinishLoadingStyle:
{
- [self.style willChangeValueForKey:@"name"];
- [self.style willChangeValueForKey:@"sources"];
- [self.style didChangeValueForKey:@"sources"];
- [self.style willChangeValueForKey:@"layers"];
- [self.style didChangeValueForKey:@"layers"];
+ self.style = [[MGLStyle alloc] initWithMapView:self];
if ([self.delegate respondsToSelector:@selector(mapView:didFinishLoadingStyle:)])
{
[self.delegate mapView:self didFinishLoadingStyle:self.style];