diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp index 47539fb0b..3020a5494 100644 --- a/include/llmr/style/style.hpp +++ b/include/llmr/style/style.hpp @@ -19,6 +19,7 @@ class Sprite; class Source; class StyleLayer; class StyleLayerGroup; +class BackgroundProperties; class Style { public: @@ -45,10 +46,11 @@ public: bool hasTransitions() const; + const BackgroundProperties &getBackgroundProperties() const; + public: std::shared_ptr sprite; std::shared_ptr layers; - std::shared_ptr background; std::vector appliedClasses; std::string sprite_url; std::string glyph_url; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 665c7baec..253cb7eeb 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -137,8 +137,7 @@ void Painter::clear() { glStencilMask(0xFF); depthMask(true); - std::shared_ptr background_layer = map.getStyle()->background; - const BackgroundProperties &properties = background_layer ? background_layer->getProperties() : defaultStyleProperties(); + const BackgroundProperties &properties = map.getStyle()->getBackgroundProperties(); glClearColor(properties.color[0], properties.color[1], properties.color[2], properties.color[3]); glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } diff --git a/src/style/style.cpp b/src/style/style.cpp index d6894f6e1..b11cd9226 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -108,4 +108,15 @@ void Style::loadJSON(const uint8_t *const data) { updateClasses(); } +const BackgroundProperties &Style::getBackgroundProperties() const { + if (layers && layers->layers.size()) { + const auto first = layers->layers.front(); + if (first && first->id == "background") { + return first->getProperties(); + } + } + + return defaultStyleProperties(); +} + } diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 26bd54401..22f71eb7b 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -925,6 +925,7 @@ void StyleParser::parseRender(JSVal value, std::shared_ptr &layer) { } break; default: + layer->bucket.reset(); fprintf(stderr, "[WARNING] bucket type of layer '%s' is invalid\n", layer->id.c_str()); break; }