diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-03-18 17:38:56 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-03-24 20:53:55 +0200 |
commit | 20d960ed51dcd9267b7ff7a0373c72bf6e287f1f (patch) | |
tree | a78e2494a7c8c2bf621b56349254ee5e07e094e7 | |
parent | 280b80677797ceda07ddf75f567dd3613f285319 (diff) | |
download | qtlocation-mapboxgl-20d960ed51dcd9267b7ff7a0373c72bf6e287f1f.tar.gz |
[core] Layer::setProperty() can set min/max zoom and filter
-rw-r--r-- | include/mbgl/style/layer.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/layer.cpp | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 10baf19607..53e0f0f18e 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -148,6 +148,8 @@ protected: 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 diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp index efbc91434f..748f52c109 100644 --- a/src/mbgl/style/layer.cpp +++ b/src/mbgl/style/layer.cpp @@ -144,10 +144,27 @@ 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); - return error; // Must be Error{"layer doesn't support this property"}. + if (name == "minzoom") { + if (auto zoom = convert<float>(value, *error)) { + setMinZoom(*zoom); + return nullopt; + } + } else if (name == "maxzoom") { + if (auto zoom = convert<float>(value, *error)) { + setMaxZoom(*zoom); + return nullopt; + } + } else if (name == "filter") { + if (auto filter = convert<Filter>(value, *error)) { + setFilter(*filter); + return nullopt; + } + } + return error; } optional<conversion::Error> Layer::setVisibility(const conversion::Convertible& value) { |