diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-17 11:54:00 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-17 13:48:00 -0800 |
commit | 251035cd7506d00e13f9c6af441805c006f21074 (patch) | |
tree | 97a6791aafab7dad6251247f0c5ba69af3916391 /platform/node/src | |
parent | f1e10e31a5029b1efa8aeb5f81bfe274cad0fc3b (diff) | |
download | qtlocation-mapboxgl-251035cd7506d00e13f9c6af441805c006f21074.tar.gz |
[node] Add setZoom and setPitch support
Diffstat (limited to 'platform/node/src')
-rw-r--r-- | platform/node/src/node_map.cpp | 36 | ||||
-rw-r--r-- | platform/node/src/node_map.hpp | 2 |
2 files changed, 38 insertions, 0 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 43a278687a..c0f86dfb6a 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -62,7 +62,9 @@ void NodeMap::Init(v8::Local<v8::Object> target) { Nan::SetPrototypeMethod(tpl, "setPaintProperty", SetPaintProperty); Nan::SetPrototypeMethod(tpl, "setFilter", SetFilter); Nan::SetPrototypeMethod(tpl, "setCenter", SetCenter); + Nan::SetPrototypeMethod(tpl, "setZoom", SetZoom); Nan::SetPrototypeMethod(tpl, "setBearing", SetBearing); + Nan::SetPrototypeMethod(tpl, "setPitch", SetPitch); Nan::SetPrototypeMethod(tpl, "dumpDebugLogs", DumpDebugLogs); Nan::SetPrototypeMethod(tpl, "queryRenderedFeatures", QueryRenderedFeatures); @@ -725,6 +727,23 @@ void NodeMap::SetCenter(const Nan::FunctionCallbackInfo<v8::Value>& info) { info.GetReturnValue().SetUndefined(); } +void NodeMap::SetZoom(const Nan::FunctionCallbackInfo<v8::Value>& info) { + auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); + if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); + + if (info.Length() <= 0 || !info[0]->IsNumber()) { + return Nan::ThrowTypeError("First argument must be a number"); + } + + try { + nodeMap->map->setZoom(info[0]->NumberValue()); + } catch (const std::exception &ex) { + return Nan::ThrowError(ex.what()); + } + + info.GetReturnValue().SetUndefined(); +} + void NodeMap::SetBearing(const Nan::FunctionCallbackInfo<v8::Value>& info) { auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); @@ -742,6 +761,23 @@ void NodeMap::SetBearing(const Nan::FunctionCallbackInfo<v8::Value>& info) { info.GetReturnValue().SetUndefined(); } +void NodeMap::SetPitch(const Nan::FunctionCallbackInfo<v8::Value>& info) { + auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); + if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); + + if (info.Length() <= 0 || !info[0]->IsNumber()) { + return Nan::ThrowTypeError("First argument must be a number"); + } + + try { + nodeMap->map->setPitch(info[0]->NumberValue()); + } catch (const std::exception &ex) { + return Nan::ThrowError(ex.what()); + } + + info.GetReturnValue().SetUndefined(); +} + void NodeMap::DumpDebugLogs(const Nan::FunctionCallbackInfo<v8::Value>& info) { auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index 45de2733cc..20ed1af4f4 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -41,7 +41,9 @@ public: static void SetPaintProperty(const Nan::FunctionCallbackInfo<v8::Value>&); static void SetFilter(const Nan::FunctionCallbackInfo<v8::Value>&); static void SetCenter(const Nan::FunctionCallbackInfo<v8::Value>&); + static void SetZoom(const Nan::FunctionCallbackInfo<v8::Value>&); static void SetBearing(const Nan::FunctionCallbackInfo<v8::Value>&); + static void SetPitch(const Nan::FunctionCallbackInfo<v8::Value>&); static void DumpDebugLogs(const Nan::FunctionCallbackInfo<v8::Value>&); static void QueryRenderedFeatures(const Nan::FunctionCallbackInfo<v8::Value>&); |