From 251035cd7506d00e13f9c6af441805c006f21074 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 17 Nov 2016 11:54:00 -0800 Subject: [node] Add setZoom and setPitch support --- platform/node/src/node_map.cpp | 36 ++++++++++++++++++++++++++++++++++++ platform/node/src/node_map.hpp | 2 ++ 2 files changed, 38 insertions(+) (limited to 'platform/node/src') 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 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& info) { info.GetReturnValue().SetUndefined(); } +void NodeMap::SetZoom(const Nan::FunctionCallbackInfo& info) { + auto nodeMap = Nan::ObjectWrap::Unwrap(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& info) { auto nodeMap = Nan::ObjectWrap::Unwrap(info.Holder()); if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); @@ -742,6 +761,23 @@ void NodeMap::SetBearing(const Nan::FunctionCallbackInfo& info) { info.GetReturnValue().SetUndefined(); } +void NodeMap::SetPitch(const Nan::FunctionCallbackInfo& info) { + auto nodeMap = Nan::ObjectWrap::Unwrap(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& info) { auto nodeMap = Nan::ObjectWrap::Unwrap(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&); static void SetFilter(const Nan::FunctionCallbackInfo&); static void SetCenter(const Nan::FunctionCallbackInfo&); + static void SetZoom(const Nan::FunctionCallbackInfo&); static void SetBearing(const Nan::FunctionCallbackInfo&); + static void SetPitch(const Nan::FunctionCallbackInfo&); static void DumpDebugLogs(const Nan::FunctionCallbackInfo&); static void QueryRenderedFeatures(const Nan::FunctionCallbackInfo&); -- cgit v1.2.1