summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLLineStyleLayer.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLLineStyleLayer.mm')
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.mm62
1 files changed, 5 insertions, 57 deletions
diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm
index e37489cf0b..b04b238fe2 100644
--- a/platform/darwin/src/MGLLineStyleLayer.mm
+++ b/platform/darwin/src/MGLLineStyleLayer.mm
@@ -2,14 +2,14 @@
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
#import "MGLSource.h"
-#import "MGLMapView_Private.h"
#import "NSPredicate+MGLAdditions.h"
#import "NSDate+MGLAdditions.h"
#import "MGLStyleLayer_Private.h"
+#import "MGLForegroundStyleLayer_Private.h"
#import "MGLStyleValue_Private.h"
#import "MGLLineStyleLayer.h"
-#include <mbgl/map/map.hpp>
+#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/layers/line_layer.hpp>
namespace mbgl {
@@ -35,23 +35,16 @@ namespace mbgl {
@interface MGLLineStyleLayer ()
-@property (nonatomic) mbgl::style::LineLayer *rawLayer;
+@property (nonatomic, readonly) mbgl::style::LineLayer *rawLayer;
@end
@implementation MGLLineStyleLayer
-{
- std::unique_ptr<mbgl::style::LineLayer> _pendingLayer;
-}
- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source
{
- if (self = [super initWithIdentifier:identifier source:source]) {
- auto layer = std::make_unique<mbgl::style::LineLayer>(identifier.UTF8String, source.identifier.UTF8String);
- _pendingLayer = std::move(layer);
- self.rawLayer = _pendingLayer.get();
- }
- return self;
+ auto layer = std::make_unique<mbgl::style::LineLayer>(identifier.UTF8String, source.identifier.UTF8String);
+ return self = [super initWithPendingLayer:std::move(layer) source:source];
}
- (mbgl::style::LineLayer *)rawLayer
@@ -59,11 +52,6 @@ namespace mbgl {
return (mbgl::style::LineLayer *)super.rawLayer;
}
-- (void)setRawLayer:(mbgl::style::LineLayer *)rawLayer
-{
- super.rawLayer = rawLayer;
-}
-
- (NSString *)sourceIdentifier
{
MGLAssertStyleLayerIsValid();
@@ -100,46 +88,6 @@ namespace mbgl {
return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
}
-#pragma mark - Adding to and removing from a map view
-
-- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer
-{
- if (_pendingLayer == nullptr) {
- [NSException raise:@"MGLRedundantLayerException"
- format:@"This instance %@ was already added to %@. Adding the same layer instance " \
- "to the style more than once is invalid.", self, mapView.style];
- }
-
- if (otherLayer) {
- const mbgl::optional<std::string> belowLayerId{otherLayer.identifier.UTF8String};
- mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId);
- } else {
- mapView.mbglMap->addLayer(std::move(_pendingLayer));
- }
-}
-
-- (void)removeFromMapView:(MGLMapView *)mapView
-{
- if (self.rawLayer != mapView.mbglMap->getLayer(self.identifier.UTF8String)) {
- return;
- }
-
- auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String);
- if (!removedLayer) {
- return;
- }
-
- mbgl::style::LineLayer *layer = dynamic_cast<mbgl::style::LineLayer *>(removedLayer.get());
- if (!layer) {
- return;
- }
-
- removedLayer.release();
-
- _pendingLayer = std::unique_ptr<mbgl::style::LineLayer>(layer);
- self.rawLayer = _pendingLayer.get();
-}
-
#pragma mark - Accessing the Layout Attributes
- (void)setLineCap:(MGLStyleValue<NSValue *> *)lineCap {