diff options
Diffstat (limited to 'src/mbgl/annotation/line_annotation_impl.cpp')
-rw-r--r-- | src/mbgl/annotation/line_annotation_impl.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp index f18ca9fadc..5ec5a2a49f 100644 --- a/src/mbgl/annotation/line_annotation_impl.cpp +++ b/src/mbgl/annotation/line_annotation_impl.cpp @@ -13,17 +13,20 @@ LineAnnotationImpl::LineAnnotationImpl(AnnotationID id_, LineAnnotation annotati } void LineAnnotationImpl::updateStyle(Style& style) const { - if (style.getLayer(layerID)) - return; - - std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>(layerID, AnnotationManager::SourceID); - layer->setSourceLayer(layerID); - layer->setLineJoin(LineJoinType::Round); - layer->setLineOpacity(annotation.opacity); - layer->setLineWidth(annotation.width); - layer->setLineColor(annotation.color); - - style.addLayer(std::move(layer), AnnotationManager::PointLayerID); + Layer* layer = style.getLayer(layerID); + LineLayer* lineLayer = layer ? layer->as<LineLayer>() : nullptr; + + if (!lineLayer) { + lineLayer = style.addLayer( + std::make_unique<LineLayer>(layerID, AnnotationManager::SourceID), + AnnotationManager::PointLayerID)->as<LineLayer>(); + lineLayer->setSourceLayer(layerID); + } + + lineLayer->setLineJoin(LineJoinType::Round); + lineLayer->setLineOpacity(annotation.opacity); + lineLayer->setLineWidth(annotation.width); + lineLayer->setLineColor(annotation.color); } const ShapeAnnotationGeometry& LineAnnotationImpl::geometry() const { |