summaryrefslogtreecommitdiff
path: root/platform/node
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-21 16:28:18 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-21 16:30:35 -0700
commit220fc7adc952c97db3fb8ce7edb855db9469ef5a (patch)
treee4aefba88a7d57ccf0ab40789832978215699da3 /platform/node
parent8a9ee26b0e00a899a77c265d6d5e33b3aa11b582 (diff)
downloadqtlocation-mapboxgl-220fc7adc952c97db3fb8ce7edb855db9469ef5a.tar.gz
[node] Support setLayoutProperty(..., "visibility", ...)
Diffstat (limited to 'platform/node')
-rw-r--r--platform/node/src/node_style.hpp18
-rw-r--r--platform/node/src/node_style_properties.hpp2
-rw-r--r--platform/node/src/node_style_properties.hpp.ejs2
3 files changed, 22 insertions, 0 deletions
diff --git a/platform/node/src/node_style.hpp b/platform/node/src/node_style.hpp
index 032e0c8a43..9befd00d10 100644
--- a/platform/node/src/node_style.hpp
+++ b/platform/node/src/node_style.hpp
@@ -46,4 +46,22 @@ PropertySetter makePropertySetter(void (L::*setter)(mbgl::style::PropertyValue<V
};
}
+inline bool setVisibility(mbgl::style::Layer& layer, const v8::Local<v8::Value>& value) {
+ if (value->IsNull() || value->IsUndefined()) {
+ layer.setVisibility(mbgl::style::VisibilityType::Visible);
+ return true;
+ }
+
+ if (!value->IsString()) {
+ Nan::ThrowTypeError("visibility value must be \"visible\" or \"none\"");
+ return false;
+ }
+
+ layer.setVisibility(std::string(*Nan::Utf8String(value)) == "none"
+ ? mbgl::style::VisibilityType::None
+ : mbgl::style::VisibilityType::Visible);
+
+ return true;
+}
+
}
diff --git a/platform/node/src/node_style_properties.hpp b/platform/node/src/node_style_properties.hpp
index 88142f8e1f..1ad06068f3 100644
--- a/platform/node/src/node_style_properties.hpp
+++ b/platform/node/src/node_style_properties.hpp
@@ -13,6 +13,8 @@ inline PropertySetters makeLayoutPropertySetters() {
using namespace mbgl::style;
PropertySetters result;
+ result["visibility"] = &setVisibility;
+
result["line-cap"] = makePropertySetter(&LineLayer::setLineCap);
result["line-join"] = makePropertySetter(&LineLayer::setLineJoin);
diff --git a/platform/node/src/node_style_properties.hpp.ejs b/platform/node/src/node_style_properties.hpp.ejs
index 1937421fa5..ebf45eb3cf 100644
--- a/platform/node/src/node_style_properties.hpp.ejs
+++ b/platform/node/src/node_style_properties.hpp.ejs
@@ -10,6 +10,8 @@ inline PropertySetters makeLayoutPropertySetters() {
using namespace mbgl::style;
PropertySetters result;
+ result["visibility"] = &setVisibility;
+
<% for (const layer of locals.layers) { -%>
<% for (const property of layer.layoutProperties) { -%>
result["<%- property.name %>"] = makePropertySetter(&<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>);