[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

@@ -23,7 +23,7 @@
"express": "^4.11.1",
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#4d1f89514bf03536c8e682439df165c33a37122a",
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#83b1a3e5837d785af582efd5ed1a212f2df6a4ae",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#d4c5c157397a2df619ba1eecf69a08b34159b3e1",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#3fabb909ba50af1175a2409e9a3cda56fb41b5c7",
"node-gyp": "^3.3.1",
"request": "^2.72.0",
"tape": "^4.5.1"

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;

View File

@@ -28,6 +28,7 @@ public:
static NAN_METHOD(AddClass);
static NAN_METHOD(AddSource);
static NAN_METHOD(AddLayer);
static NAN_METHOD(RemoveLayer);
static NAN_METHOD(SetLayoutProperty);
static NAN_METHOD(SetPaintProperty);
static NAN_METHOD(SetFilter);