diff options
Diffstat (limited to 'src/mbgl/map/map_context.cpp')
-rw-r--r-- | src/mbgl/map/map_context.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index a27d7301a5..5b1825bff2 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -99,6 +99,8 @@ void MapContext::setStyleURL(const std::string& url) { styleURL = url; styleJSON.clear(); + style = std::make_unique<Style>(data, asyncUpdate->get()->loop); + const size_t pos = styleURL.rfind('/'); std::string base = ""; if (pos != std::string::npos) { @@ -120,14 +122,15 @@ void MapContext::setStyleJSON(const std::string& json, const std::string& base) styleURL.clear(); styleJSON = json; + style = std::make_unique<Style>(data, asyncUpdate->get()->loop); + loadStyleJSON(json, base); } void MapContext::loadStyleJSON(const std::string& json, const std::string& base) { assert(util::ThreadContext::currentlyOn(util::ThreadType::Map)); - style.reset(); - style = std::make_unique<Style>(json, base, data, asyncUpdate->get()->loop); + style->setJSON(json, base); style->cascade(data.getClasses()); style->setDefaultTransitionDuration(data.getDefaultTransitionDuration()); style->setObserver(this); @@ -376,7 +379,10 @@ void MapContext::onLowMemory() { } void MapContext::setSprite(const std::string& name, std::shared_ptr<const SpriteImage> sprite) { - if (!style) return; + if (!style) { + Log::Info(Event::Sprite, "Ignoring sprite without stylesheet"); + return; + } style->spriteStore->setSprite(name, sprite); |