diff options
Diffstat (limited to 'platform/darwin/src/MGLLineStyleLayer.mm')
-rw-r--r-- | platform/darwin/src/MGLLineStyleLayer.mm | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index aa699ea37d..c7509e2870 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -53,6 +53,31 @@ return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } + +#pragma mark - Adding to and removing from a map view + +- (void)addToMapView:(MGLMapView *)mapView +{ + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + 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 +{ + auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String); + _pendingLayer = std::move(reinterpret_cast<std::unique_ptr<mbgl::style::LineLayer> &>(removedLayer)); + self.rawLayer = _pendingLayer.get(); +} + #pragma mark - Accessing the Layout Attributes - (void)setLineCap:(MGLStyleValue<NSValue *> *)lineCap { @@ -198,21 +223,4 @@ } -#pragma mark - Add style layer to map - -- (void)addToMapView:(MGLMapView *)mapView -{ - [self addToMapView:mapView belowLayer:nil]; -} - -- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer -{ - 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)); - } -} - @end |