[core] Removed map attribution API
Since client code can readily access the individual sources, Map doesn’t need to expose a dedicated API for iterating over them.
This commit is contained in:
committed by
Minh Nguyễn
parent
a9842dbd6b
commit
7ff036cd01
@@ -155,7 +155,6 @@ public:
|
||||
style::Source* getSource(const std::string& sourceID);
|
||||
void addSource(std::unique_ptr<style::Source>);
|
||||
void removeSource(const std::string& sourceID);
|
||||
std::vector<std::string> getAttributions() const;
|
||||
|
||||
// Layers
|
||||
style::Layer* getLayer(const std::string& layerID);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
|
||||
#include <memory>
|
||||
@@ -50,6 +51,8 @@ public:
|
||||
// are copied from this source.
|
||||
std::unique_ptr<Source> copy(const std::string& id) const;
|
||||
|
||||
optional<std::string> getAttribution() const;
|
||||
|
||||
// Private implementation
|
||||
class Impl;
|
||||
const std::unique_ptr<Impl> baseImpl;
|
||||
|
||||
@@ -786,10 +786,6 @@ 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;
|
||||
|
||||
@@ -14,5 +14,9 @@ const std::string& Source::getID() const {
|
||||
return baseImpl->id;
|
||||
}
|
||||
|
||||
optional<std::string> Source::getAttribution() const {
|
||||
return baseImpl->getAttribution();
|
||||
}
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -71,6 +71,8 @@ public:
|
||||
const SourceType type;
|
||||
const std::string id;
|
||||
|
||||
virtual optional<std::string> getAttribution() const { return {}; };
|
||||
|
||||
bool loaded = false;
|
||||
|
||||
// Tracks whether the source is used by any layers visible at the current zoom level. Must
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <mbgl/style/update_parameters.hpp>
|
||||
#include <mbgl/style/cascade_parameters.hpp>
|
||||
#include <mbgl/style/calculation_parameters.hpp>
|
||||
#include <mbgl/style/tile_source_impl.hpp>
|
||||
#include <mbgl/sprite/sprite_atlas.hpp>
|
||||
#include <mbgl/text/glyph_atlas.hpp>
|
||||
#include <mbgl/geometry/line_atlas.hpp>
|
||||
@@ -26,7 +25,6 @@
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/tileset.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/math/minmax.hpp>
|
||||
|
||||
@@ -295,28 +293,6 @@ Source* Style::getSource(const std::string& id) const {
|
||||
return it != sources.end() ? it->get() : nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::string> Style::getAttributions() const {
|
||||
std::vector<std::string> result;
|
||||
for (const auto& source : sources) {
|
||||
switch (source->baseImpl->type) {
|
||||
case SourceType::Vector:
|
||||
case SourceType::Raster: {
|
||||
style::TileSourceImpl* tileSource = static_cast<style::TileSourceImpl*>(source->baseImpl.get());
|
||||
auto attribution = tileSource->getAttribution();
|
||||
if (!attribution.empty()) {
|
||||
result.push_back(std::move(attribution));
|
||||
}
|
||||
}
|
||||
|
||||
case SourceType::GeoJSON:
|
||||
case SourceType::Video:
|
||||
case SourceType::Annotations:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Style::hasTransitions() const {
|
||||
return hasPendingTransitions;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
Source* getSource(const std::string& id) const;
|
||||
void addSource(std::unique_ptr<Source>);
|
||||
void removeSource(const std::string& sourceID);
|
||||
std::vector<std::string> getAttributions() const;
|
||||
|
||||
std::vector<const Layer*> getLayers() const;
|
||||
Layer* getLayer(const std::string& id) const;
|
||||
|
||||
@@ -118,8 +118,12 @@ Range<uint8_t> TileSourceImpl::getZoomRange() {
|
||||
return tileset.zoomRange;
|
||||
}
|
||||
|
||||
std::string TileSourceImpl::getAttribution() const {
|
||||
return loaded ? tileset.attribution : "";
|
||||
optional<std::string> TileSourceImpl::getAttribution() const {
|
||||
if (loaded && !tileset.attribution.empty()) {
|
||||
return tileset.attribution;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
return urlOrTileset;
|
||||
}
|
||||
|
||||
std::string getAttribution() const;
|
||||
optional<std::string> getAttribution() const override;
|
||||
|
||||
protected:
|
||||
Range<uint8_t> getZoomRange() final;
|
||||
|
||||
Reference in New Issue
Block a user