[core] Source-driven attribution

Implemented observer callbacks so the style knows when the source’s attribution changes and the map knows when the style’s attribution changes. Also implemented a getter for a tile source’s attribution.

Fixes #2723.
This commit is contained in:
Minh Nguyễn
2016-08-13 11:30:15 -07:00
committed by Minh Nguyễn
parent 78af55f30a
commit f307652548
13 changed files with 103 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ using namespace mbgl;
using namespace mbgl::style;
/**
* An implementation of style::Observer that forwards all methods to dynamically-settable lambas.
* An implementation of style::Observer that forwards all methods to dynamically-settable lambdas.
*/
class StubStyleObserver : public style::Observer {
public:
@@ -30,6 +30,10 @@ public:
if (sourceLoaded) sourceLoaded(source);
}
void onSourceAttributionChanged(Source& source, const std::string& attribution) override {
if (sourceAttributionChanged) sourceAttributionChanged(source, attribution);
}
void onSourceError(Source& source, std::exception_ptr error) override {
if (sourceError) sourceError(source, error);
}
@@ -52,6 +56,7 @@ public:
std::function<void ()> spriteLoaded;
std::function<void (std::exception_ptr)> spriteError;
std::function<void (Source&)> sourceLoaded;
std::function<void (Source&, std::string)> sourceAttributionChanged;
std::function<void (Source&, std::exception_ptr)> sourceError;
std::function<void (Source&, const OverscaledTileID&)> tileChanged;
std::function<void (Source&, const OverscaledTileID&, std::exception_ptr)> tileError;