[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

@@ -38,6 +38,7 @@ class Map::Impl : public style::Observer {
public:
Impl(View&, FileSource&, MapMode, GLContextMode, ConstrainMode, ViewportMode);
void onSourceAttributionChanged(style::Source&, const std::string&) override;
void onUpdate(Update) override;
void onStyleLoaded() override;
void onStyleError() override;
@@ -785,6 +786,10 @@ void Map::removeSource(const std::string& sourceID) {
}
}
std::vector<std::string> Map::getAttributions() const {
return impl->style ? impl->style->getAttributions() : std::vector<std::string>();
}
style::Layer* Map::getLayer(const std::string& layerID) {
if (impl->style) {
impl->styleMutated = true;
@@ -980,6 +985,10 @@ void Map::onLowMemory() {
impl->view.invalidate();
}
void Map::Impl::onSourceAttributionChanged(style::Source&, const std::string&) {
view.notifyMapChange(MapChangeSourceAttributionDidChange);
}
void Map::Impl::onUpdate(Update flags) {
if (flags & Update::Dimensions) {
transform.resize(view.getSize());