summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-18 17:38:56 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-24 20:53:55 +0200
commit20d960ed51dcd9267b7ff7a0373c72bf6e287f1f (patch)
treea78e2494a7c8c2bf621b56349254ee5e07e094e7
parent280b80677797ceda07ddf75f567dd3613f285319 (diff)
downloadqtlocation-mapboxgl-20d960ed51dcd9267b7ff7a0373c72bf6e287f1f.tar.gz
[core] Layer::setProperty() can set min/max zoom and filter
-rw-r--r--include/mbgl/style/layer.hpp2
-rw-r--r--src/mbgl/style/layer.cpp21
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) {