[ios, macos] Snapshotter (runtime styling) delegates

Added a protocol and property for MGLMapSnapshotter’s delegate, which it uses for runtime styling. Generalized MGLStyle to be usable in the absence of MGLMapView. Moved MGLOpenGLStyleLayer code around to compile.
This commit is contained in:
Minh Nguyễn
2020-03-23 02:12:38 -07:00
committed by Minh Nguyễn
parent 180ab72055
commit 63bf91125a
17 changed files with 269 additions and 100 deletions

View File

@@ -15,6 +15,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
### Snapshots
* Added the `MGLMapSnapshotter.delegate` property and `MGLMapSnapshotterDelegate` protocol for customizing the style before taking a snapshot. ([#235](https://github.com/mapbox/mapbox-gl-native-ios/pull/235))
* You no longer need to explicitly capture the `MGLMapSnapshotter` object in the completion handler that you specify in `-[MGLMapSnapshotter startWithCompletionHandler:]`. Even if you declare the snapshotter locally without holding a strong reference to it, the snapshotter is only deallocated after the completion handler finishes, and the completion handler generally receives a valid snapshot. ([#210](https://github.com/mapbox/mapbox-gl-native-ios/pull/210))
* The `-[MGLMapSnapshotter cancel]` method no longer calls the completion handler passed into `-[MGLMapSnapshotter startWithCompletionHandler:]`. ([#210](https://github.com/mapbox/mapbox-gl-native-ios/pull/210))
* Fixed an issue where the `MGLMapSnapshotter.loading` property always returned `NO`, even while loading a snapshot. ([#210](https://github.com/mapbox/mapbox-gl-native-ios/pull/210))

View File

@@ -50,7 +50,7 @@ void MGLMapViewImpl::onDidFailLoadingMap(mbgl::MapLoadError mapError, const std:
break;
case mbgl::MapLoadError::StyleLoadError:
code = MGLErrorCodeLoadStyleFailed;
description = NSLocalizedStringWithDefaultValue(@"LOAD_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style can't be loaded.", @"User-friendly error description");
description = NSLocalizedStringWithDefaultValue(@"LOAD_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style can’t be loaded.", @"User-friendly error description");
break;
case mbgl::MapLoadError::NotFoundError:
code = MGLErrorCodeNotFound;

View File

@@ -5,6 +5,7 @@
#import "MGLGeometry.h"
#import "MGLMapCamera.h"
#import "MGLTypes.h"
#import "MGLStyle.h"
NS_ASSUME_NONNULL_BEGIN
@@ -14,7 +15,6 @@ NS_ASSUME_NONNULL_BEGIN
@class MGLPolyline;
@class MGLPolygon;
@class MGLShape;
@class MGLStyle;
@protocol MGLMapViewDelegate;
@protocol MGLAnnotation;
@@ -188,7 +188,7 @@ FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLUserLocationAnnotationTyp
Simple map view</a> example to learn how to initialize a basic `MGLMapView`.
*/
MGL_EXPORT
@interface MGLMapView : UIView
@interface MGLMapView : UIView <MGLStylable>
#pragma mark Creating Instances

View File

@@ -6459,7 +6459,7 @@ public:
return;
}
self.style = [[MGLStyle alloc] initWithRawStyle:&self.mbglMap.getStyle() mapView:self];
self.style = [[MGLStyle alloc] initWithRawStyle:&self.mbglMap.getStyle() stylable:self];
if ([self.delegate respondsToSelector:@selector(mapView:didFinishLoadingStyle:)])
{
[self.delegate mapView:self didFinishLoadingStyle:self.style];