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(); }
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)); } }
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(); }