Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Layer::setProperty() can set min/max zoom and filter
Browse files Browse the repository at this point in the history
  • Loading branch information
pozdnyakov committed Mar 19, 2020
1 parent 2fa0dbe commit 2e03ca1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/mbgl/style/layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class Layer {

private:
optional<conversion::Error> setVisibility(const conversion::Convertible& value);
optional<conversion::Error> setMinZoom(const conversion::Convertible& value);
optional<conversion::Error> setMaxZoom(const conversion::Convertible& value);
};

} // namespace style
Expand Down
10 changes: 9 additions & 1 deletion src/mbgl/style/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,17 @@ void Layer::setObserver(LayerObserver* observer_) {
}

optional<conversion::Error> Layer::setProperty(const std::string& name, const conversion::Convertible& value) {
optional<conversion::Error> error = setPropertyInternal(name, value);
using namespace conversion;
optional<Error> error = setPropertyInternal(name, value);
if (!error) return error; // Successfully set by the derived class implementation.
if (name == "visibility") return setVisibility(value);
if (name == "min-zoom") {
if (auto zoom = convert<float>(value, *error)) setMinZoom(*zoom);
} else if (name == "max-zoom") {
if (auto zoom = convert<float>(value, *error)) setMaxZoom(*zoom);
} else if (name == "filter") {
if (auto filter = convert<Filter>(value, *error)) setFilter(*filter);
}
return error; // Must be Error{"layer doesn't support this property"}.
}

Expand Down

0 comments on commit 2e03ca1

Please sign in to comment.