summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/style_sourced_annotation_impl.cpp
blob: 5d8f1f0da15dd186035987b74903f482a25f2684 (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
34
35
36
37
38
#include <mbgl/annotation/style_sourced_annotation_impl.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layer.hpp>

namespace mbgl {

namespace geojsonvt = mapbox::geojsonvt;

StyleSourcedAnnotationImpl::StyleSourcedAnnotationImpl(const AnnotationID id_, const StyleSourcedAnnotation& annotation_, const uint8_t maxZoom_)
    : ShapeAnnotationImpl(id_, maxZoom_),
      annotation(annotation_) {
}

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

    const StyleLayer* sourceLayer = style.getLayer(annotation.layerID);
    if (!sourceLayer)
        return;

    std::unique_ptr<StyleLayer> layer = sourceLayer->clone();

    layer->id = layerID;
    layer->ref = "";
    layer->source = AnnotationManager::SourceID;
    layer->sourceLayer = layer->id;
    layer->visibility = VisibilityType::Visible;

    style.addLayer(std::move(layer), sourceLayer->id);
}

const Geometry<double>& StyleSourcedAnnotationImpl::geometry() const {
    return annotation.geometry;
}

} // namespace mbgl