diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-07-13 14:05:20 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-07-13 16:19:28 +0300 |
commit | 1cb59e20c4cdb8c182ecb9d3fd2abd062f5cb4da (patch) | |
tree | cc4ac0ff5b8813c4411071c57c363ad994310e9a | |
parent | 3dacbdd42ead4a9fd883837776584fcd8da91f81 (diff) | |
download | qtlocation-mapboxgl-1cb59e20c4cdb8c182ecb9d3fd2abd062f5cb4da.tar.gz |
[node] Added 'removeLayer' binding
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 19 | ||||
-rw-r--r-- | platform/node/src/node_map.hpp | 1 |
3 files changed, 21 insertions, 1 deletions
diff --git a/package.json b/package.json index ac3cd446c5..39b83283d5 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 77d650e2e9..9a8941d790 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -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; diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index d64d58013d..5090b0aedc 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -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); |