[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

@@ -46,6 +46,7 @@
### Snapshots
* Added an `-[MGLMapSnapshotter startWithOverlayHandler:completionHandler:]` method to provide the snapshot's current `CGContext` in order to perform custom drawing on `MGLMapSnapshot` objects. ([#15530](https://github.com/mapbox/mapbox-gl-native/pull/15530))
* 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

@@ -4,12 +4,12 @@
#import "MGLFoundation.h"
#import "MGLTypes.h"
#import "MGLGeometry.h"
#import "MGLStyle.h"
NS_ASSUME_NONNULL_BEGIN
@class MGLAnnotationImage;
@class MGLMapCamera;
@class MGLStyle;
@class MGLShape;
@protocol MGLAnnotation;
@@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN
ensuring that your use adheres to the relevant terms of use.
*/
MGL_EXPORT IB_DESIGNABLE
@interface MGLMapView : NSView
@interface MGLMapView : NSView <MGLStylable>
#pragma mark Creating Instances

View File

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