summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/fill_annotation_impl.cpp
blob: cbd76ede97f71970db1006d9852d1b78b4fa89ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <mbgl/annotation/fill_annotation_impl.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/layers/fill_layer.hpp>

namespace mbgl {

using namespace style;

FillAnnotationImpl::FillAnnotationImpl(AnnotationID id_, FillAnnotation annotation_, uint8_t maxZoom_)
    : ShapeAnnotationImpl(id_, maxZoom_),
      annotation(std::move(annotation_)) {
}

void FillAnnotationImpl::updateStyle(Style& style) const {
    if (style.getLayer(layerID))
        return;

    std::unique_ptr<FillLayer> layer = std::make_unique<FillLayer>(layerID);
    layer->setSource(AnnotationManager::SourceID, layerID);

    layer->setFillOpacity(annotation.opacity);
    layer->setFillColor(annotation.color);
    layer->setFillOutlineColor(annotation.outlineColor);

    style.addLayer(std::move(layer), AnnotationManager::PointLayerID);
}

const ShapeAnnotationGeometry& FillAnnotationImpl::geometry() const {
    return annotation.geometry;
}

} // namespace mbgl