Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[node] Added 'removeLayer' binding
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Jul 13, 2016
1 parent 3dacbdd commit 1cb59e2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 19 additions & 0 deletions platform/node/src/node_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions platform/node/src/node_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class NodeMap : public Nan::ObjectWrap,
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);
Expand Down

0 comments on commit 1cb59e2

Please sign in to comment.