summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/line_annotation_impl.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-08-27 15:26:15 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-08-29 08:08:44 -0700
commite126dc3a5a3857b24246432153b0554d630b6234 (patch)
tree55cfde3bb7ed61dba029537f030a4d43f2d4c9c2 /src/mbgl/annotation/line_annotation_impl.cpp
parentd9f63c6d76ff33dfbefa57eb124efe10d5c7592a (diff)
downloadqtlocation-mapboxgl-e126dc3a5a3857b24246432153b0554d630b6234.tar.gz
[core] Fix updates of line and fill annotations
Diffstat (limited to 'src/mbgl/annotation/line_annotation_impl.cpp')
-rw-r--r--src/mbgl/annotation/line_annotation_impl.cpp25
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 {