diff options
Diffstat (limited to 'platform/ios/src')
-rw-r--r-- | platform/ios/src/MGLMapView+MGLCustomStyleLayerAdditions.h | 26 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 82 | ||||
-rw-r--r-- | platform/ios/src/Mapbox.h | 2 |
3 files changed, 6 insertions, 104 deletions
diff --git a/platform/ios/src/MGLMapView+MGLCustomStyleLayerAdditions.h b/platform/ios/src/MGLMapView+MGLCustomStyleLayerAdditions.h deleted file mode 100644 index de4dc01f99..0000000000 --- a/platform/ios/src/MGLMapView+MGLCustomStyleLayerAdditions.h +++ /dev/null @@ -1,26 +0,0 @@ -#import "MGLMapView.h" - -NS_ASSUME_NONNULL_BEGIN - -typedef void (^MGLCustomStyleLayerPreparationHandler)(void); - -typedef void (^MGLCustomStyleLayerDrawingHandler)(CGSize size, - CLLocationCoordinate2D centerCoordinate, - double zoomLevel, - CLLocationDirection direction, - CGFloat pitch, - CGFloat perspectiveSkew); - -typedef void (^MGLCustomStyleLayerCompletionHandler)(void); - -@interface MGLMapView (MGLCustomStyleLayerAdditions) - -- (void)insertCustomStyleLayerWithIdentifier:(NSString *)identifier preparationHandler:(MGLCustomStyleLayerPreparationHandler)preparation drawingHandler:(MGLCustomStyleLayerDrawingHandler)drawing completionHandler:(MGLCustomStyleLayerCompletionHandler)completion belowStyleLayerWithIdentifier:(nullable NSString *)otherIdentifier; - -- (void)removeCustomStyleLayerWithIdentifier:(NSString *)identifier; - -- (void)setCustomStyleLayersNeedDisplay; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index e6fed8639c..3ee03182a8 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -378,6 +378,11 @@ public: self.styleURL = styleURL; } +- (mbgl::Map *)mbglMap +{ + return _mbglMap; +} + - (void)commonInit { MGLinitializeRunLoop(); @@ -5336,80 +5341,3 @@ private: } @end - -#pragma mark - MGLCustomStyleLayerAdditions methods - -class MGLCustomStyleLayerHandlers -{ -public: - MGLCustomStyleLayerHandlers(MGLCustomStyleLayerPreparationHandler p, - MGLCustomStyleLayerDrawingHandler d, - MGLCustomStyleLayerCompletionHandler f) - : prepare(p), draw(d), finish(f) {} - - MGLCustomStyleLayerPreparationHandler prepare; - MGLCustomStyleLayerDrawingHandler draw; - MGLCustomStyleLayerCompletionHandler finish; -}; - -void MGLPrepareCustomStyleLayer(void *context) -{ - MGLCustomStyleLayerPreparationHandler prepare = reinterpret_cast<MGLCustomStyleLayerHandlers *>(context)->prepare; - if (prepare) - { - prepare(); - } -} - -void MGLDrawCustomStyleLayer(void *context, const mbgl::style::CustomLayerRenderParameters ¶ms) -{ - CGSize size = CGSizeMake(params.width, params.height); - CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(params.latitude, params.longitude); - double zoomLevel = params.zoom; - CLLocationDirection direction = mbgl::util::wrap(params.bearing, 0., 360.); - CGFloat pitch = params.pitch; - CGFloat perspectiveSkew = params.altitude; - MGLCustomStyleLayerDrawingHandler draw = reinterpret_cast<MGLCustomStyleLayerHandlers *>(context)->draw; - if (draw) - { - draw(size, centerCoordinate, zoomLevel, direction, pitch, perspectiveSkew); - } -} - -void MGLFinishCustomStyleLayer(void *context) -{ - MGLCustomStyleLayerHandlers *handlers = reinterpret_cast<MGLCustomStyleLayerHandlers *>(context); - MGLCustomStyleLayerCompletionHandler finish = handlers->finish; - if (finish) - { - finish(); - } - delete handlers; -} - -@implementation MGLMapView (MGLCustomStyleLayerAdditions) - -- (void)insertCustomStyleLayerWithIdentifier:(NSString *)identifier preparationHandler:(void (^)())preparation drawingHandler:(MGLCustomStyleLayerDrawingHandler)drawing completionHandler:(void (^)())completion belowStyleLayerWithIdentifier:(nullable NSString *)otherIdentifier -{ - NSAssert(identifier, @"Style layer needs an identifier"); - MGLCustomStyleLayerHandlers *context = new MGLCustomStyleLayerHandlers(preparation, drawing, completion); - _mbglMap->addLayer(std::make_unique<mbgl::style::CustomLayer>(identifier.UTF8String, MGLPrepareCustomStyleLayer, - MGLDrawCustomStyleLayer, MGLFinishCustomStyleLayer, context), - otherIdentifier ? mbgl::optional<std::string>(otherIdentifier.UTF8String) : mbgl::optional<std::string>()); -} - -- (void)removeCustomStyleLayerWithIdentifier:(NSString *)identifier -{ - _mbglMap->removeLayer(identifier.UTF8String); -} - -- (void)setCustomStyleLayersNeedDisplay -{ - [self setNeedsGLDisplay]; -} - -- (mbgl::Map *)mbglMap { - return _mbglMap; -} - -@end diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index 7664695315..64fc2be0d4 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -19,7 +19,6 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[]; #import "MGLMapCamera.h" #import "MGLMapView.h" #import "MGLMapView+IBAdditions.h" -#import "MGLMapView+MGLCustomStyleLayerAdditions.h" #import "MGLMapViewDelegate.h" #import "MGLMultiPoint.h" #import "MGLOfflinePack.h" @@ -42,6 +41,7 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[]; #import "MGLRasterStyleLayer.h" #import "MGLCircleStyleLayer.h" #import "MGLBackgroundStyleLayer.h" +#import "MGLOpenGLStyleLayer.h" #import "MGLSource.h" #import "MGLVectorSource.h" #import "MGLGeoJSONSource.h" |