[node] Added 'removeLayer' binding

This commit is contained in:
Bruno de Oliveira Abinader
2016-07-13 14:05:20 +03:00
parent 3dacbdd42e
commit 1cb59e20c4
3 changed files with 21 additions and 1 deletions

View File

@@ -60,6 +60,7 @@ NAN_MODULE_INIT(NodeMap::Init) {
Nan::SetPrototypeMethod(tpl, "addClass", AddClass);
Nan::SetPrototypeMethod(tpl, "addSource", AddSource);
Nan::SetPrototypeMethod(tpl, "addLayer", AddLayer);
Nan::SetPrototypeMethod(tpl, "removeLayer", RemoveLayer);
Nan::SetPrototypeMethod(tpl, "setLayoutProperty", SetLayoutProperty);
Nan::SetPrototypeMethod(tpl, "setPaintProperty", SetPaintProperty);
Nan::SetPrototypeMethod(tpl, "setFilter", SetFilter);
@@ -531,6 +532,24 @@ NAN_METHOD(NodeMap::AddLayer) {
nodeMap->map->addLayer(std::move(*layer));
}
NAN_METHOD(NodeMap::RemoveLayer) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
if (info.Length() != 1) {
return Nan::ThrowTypeError("One argument required");
}
if (!info[0]->IsString()) {
return Nan::ThrowTypeError("First argument must be a string");
}
nodeMap->map->removeLayer(*Nan::Utf8String(info[0]));
}
NAN_METHOD(NodeMap::SetLayoutProperty) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;