[node] Support setLayoutProperty(..., "visibility", ...)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) %>);
|
||||
|
||||
Reference in New Issue
Block a user