当前位置: 首页>>代码示例>>C++>>正文


C++ Style::addLayer方法代码示例

本文整理汇总了C++中Style::addLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ Style::addLayer方法的具体用法?C++ Style::addLayer怎么用?C++ Style::addLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Style的用法示例。


在下文中一共展示了Style::addLayer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateStyle

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

    if (shape.properties.is<LineAnnotationProperties>()) {
        type = ProjectedFeatureType::LineString;

        std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>();
        layer->type = StyleLayerType::Line;
        layer->layout.join = JoinType::Round;

        const LineAnnotationProperties& properties = shape.properties.get<LineAnnotationProperties>();
        layer->paint.opacity = properties.opacity;
        layer->paint.width = properties.width;
        layer->paint.color = properties.color;

        layer->id = layerID;
        layer->source = AnnotationManager::SourceID;
        layer->sourceLayer = layer->id;

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

    } else if (shape.properties.is<FillAnnotationProperties>()) {
        type = ProjectedFeatureType::Polygon;

        std::unique_ptr<FillLayer> layer = std::make_unique<FillLayer>();
        layer->type = StyleLayerType::Fill;

        const FillAnnotationProperties& properties = shape.properties.get<FillAnnotationProperties>();
        layer->paint.opacity = properties.opacity;
        layer->paint.color = properties.color;
        layer->paint.outlineColor = properties.outlineColor;

        layer->id = layerID;
        layer->source = AnnotationManager::SourceID;
        layer->sourceLayer = layer->id;

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

    } else {
        const StyleLayer* sourceLayer = style.getLayer(shape.properties.get<std::string>());
        if (!sourceLayer) return;

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

        type = layer->type == StyleLayerType::Line
            ? ProjectedFeatureType::LineString
            : ProjectedFeatureType::Polygon;

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

        style.addLayer(std::move(layer), sourceLayer->id);
    }
}
开发者ID:zhangzhuowh,项目名称:mapbox-gl-native,代码行数:58,代码来源:shape_annotation_impl.cpp

示例2: updateStyle

void AnnotationManager::updateStyle(Style& style) {
    // Create annotation source, point layer, and point bucket
    if (!style.getSource(SourceID)) {
        std::unique_ptr<Source> source = std::make_unique<Source>(SourceType::Annotations, SourceID, "", util::tileSize, std::make_unique<SourceInfo>(), nullptr);
        source->enabled = true;
        style.addSource(std::move(source));

        std::unique_ptr<SymbolLayer> layer = std::make_unique<SymbolLayer>();
        layer->id = PointLayerID;
        layer->source = SourceID;
        layer->sourceLayer = PointLayerID;
        layer->layout.icon.image = std::string("{sprite}");
        layer->layout.icon.allowOverlap = true;
        layer->spriteAtlas = &spriteAtlas;

        style.addLayer(std::move(layer));
    }

    for (const auto& shape : shapeAnnotations) {
        shape.second->updateStyle(style);
    }

    for (const auto& layer : obsoleteShapeAnnotationLayers) {
        if (style.getLayer(layer)) {
            style.removeLayer(layer);
        }
    }

    obsoleteShapeAnnotationLayers.clear();

    for (auto& monitor : monitors) {
        monitor->update(getTile(monitor->tileID));
    }
}
开发者ID:jormon,项目名称:mapbox-gl-native,代码行数:34,代码来源:annotation_manager.cpp

示例3: updateStyle

void AnnotationManager::updateStyle(Style& style) {
    // Create annotation source, point layer, and point bucket
    if (!style.getSource(SourceID)) {
        std::unique_ptr<Source> source = std::make_unique<AnnotationSource>();
        source->baseImpl->enabled = true;
        style.addSource(std::move(source));

        std::unique_ptr<SymbolLayer> layer = std::make_unique<SymbolLayer>(PointLayerID, SourceID);

        layer->setSourceLayer(PointLayerID);
        layer->setIconImage({"{sprite}"});
        layer->setIconAllowOverlap(true);

        layer->impl->spriteAtlas = &spriteAtlas;

        style.addLayer(std::move(layer));
    }

    for (const auto& shape : shapeAnnotations) {
        shape.second->updateStyle(style);
    }

    for (const auto& layer : obsoleteShapeAnnotationLayers) {
        if (style.getLayer(layer)) {
            style.removeLayer(layer);
        }
    }

    obsoleteShapeAnnotationLayers.clear();
}
开发者ID:SylvainHocq,项目名称:mapbox-gl-native,代码行数:30,代码来源:annotation_manager.cpp

示例4: updateStyle

void AnnotationManager::updateStyle(Style& style) {
    // Create annotation source, point layer, and point bucket
    if (!style.getSource(SourceID)) {
        std::unique_ptr<Source> source = std::make_unique<Source>();
        source->info.type = SourceType::Annotations;
        source->info.source_id = SourceID;
        source->enabled = true;
        style.addSource(std::move(source));

        std::unique_ptr<SymbolLayer> layer = std::make_unique<SymbolLayer>();
        layer->id = PointLayerID;
        layer->type = StyleLayerType::Symbol;
        layer->styles.emplace(ClassID::Default, ClassProperties());

        layer->bucket = std::make_shared<StyleBucket>(layer->type);
        layer->bucket->name = layer->id;
        layer->bucket->source = SourceID;
        layer->bucket->source_layer = PointLayerID;
        layer->bucket->layout.set(PropertyKey::IconImage, ConstantFunction<std::string>("{sprite}"));
        layer->bucket->layout.set(PropertyKey::IconAllowOverlap, ConstantFunction<bool>(true));

        style.addLayer(std::move(layer));
    }

    for (const auto& shape : shapeAnnotations) {
        shape.second->updateStyle(style);
    }

    for (const auto& layer : obsoleteShapeAnnotationLayers) {
        style.removeLayer(layer);
    }

    obsoleteShapeAnnotationLayers.clear();
    style.getSource(SourceID)->invalidateTiles();
}
开发者ID:nagyistoce,项目名称:mapbox-gl-native,代码行数:35,代码来源:annotation_manager.cpp

示例5: updateStyle

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);
}
开发者ID:Gurbo,项目名称:mapbox-gl-native,代码行数:13,代码来源:line_annotation_impl.cpp

示例6: updateStyle

void FillAnnotationImpl::updateStyle(Style& style) const {
    Layer* layer = style.getLayer(layerID);

    if (!layer) {
        auto newLayer = std::make_unique<FillLayer>(layerID, AnnotationManager::SourceID);
        newLayer->setSourceLayer(layerID);
        layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
    }

    FillLayer* fillLayer = layer->as<FillLayer>();
    fillLayer->setFillOpacity(annotation.opacity);
    fillLayer->setFillColor(annotation.color);
    fillLayer->setFillOutlineColor(annotation.outlineColor);
}
开发者ID:OrdnanceSurvey,项目名称:mapbox-gl-native,代码行数:14,代码来源:fill_annotation_impl.cpp

示例7: updateStyle

void LineAnnotationImpl::updateStyle(Style& style) const {
    Layer* layer = style.getLayer(layerID);

    if (!layer) {
        auto newLayer = std::make_unique<LineLayer>(layerID, AnnotationManager::SourceID);
        newLayer->setSourceLayer(layerID);
        newLayer->setLineJoin(LineJoinType::Round);
        layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
    }

    LineLayer* lineLayer = layer->as<LineLayer>();
    lineLayer->setLineOpacity(annotation.opacity);
    lineLayer->setLineWidth(annotation.width);
    lineLayer->setLineColor(annotation.color);
}
开发者ID:OrdnanceSurvey,项目名称:mapbox-gl-native,代码行数:15,代码来源:line_annotation_impl.cpp


注:本文中的Style::addLayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。