diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-08-11 14:42:01 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-08-31 10:17:21 +0300 |
commit | 6ee8d7bb60d333c2ca8f45dc79975c38ceed45a5 (patch) | |
tree | 5b1abb46e3ec146e7c0f580525dff4ccaddc32ee /platform/node | |
parent | d43757271ee505fa4d3c734ef61944fb03c46806 (diff) | |
download | qtlocation-mapboxgl-6ee8d7bb60d333c2ca8f45dc79975c38ceed45a5.tar.gz |
[node] Set style default camera upon each test suite run
Diffstat (limited to 'platform/node')
-rw-r--r-- | platform/node/src/node_map.cpp | 18 | ||||
-rw-r--r-- | platform/node/test/suite_implementation.js | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index a2c1a0ea15..fcc394bbe5 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -170,6 +170,9 @@ std::string StringifyStyle(v8::Local<v8::Value> styleHandle) { * @function * @name load * @param {string|Object} stylesheet either an object or a JSON representation + * @param {Object} options + * @param {boolean} options.defaultStyleCamera if true, sets the default style + * camera * @returns {undefined} loads stylesheet into map * @throws {Error} if stylesheet is missing or invalid * @example @@ -207,6 +210,21 @@ void NodeMap::Load(const Nan::FunctionCallbackInfo<v8::Value>& info) { return Nan::ThrowError(ex.what()); } + if (info.Length() == 2) { + if (!info[1]->IsObject()) { + return Nan::ThrowTypeError("Second argument must be an options object"); + } + auto options = Nan::To<v8::Object>(info[1]).ToLocalChecked(); + if (Nan::Has(options, Nan::New("defaultStyleCamera").ToLocalChecked()).FromJust()) { + if (!Nan::Get(options, Nan::New("defaultStyleCamera").ToLocalChecked()).ToLocalChecked()->IsBoolean()) { + return Nan::ThrowError("Options object 'defaultStyleCamera' property must be a boolean"); + } + if (Nan::Get(options, Nan::New("cameraMutated").ToLocalChecked()).ToLocalChecked()->BooleanValue()) { + nodeMap->map->jumpTo(nodeMap->map->getStyle().getDefaultCamera()); + } + } + } + nodeMap->loaded = true; info.GetReturnValue().SetUndefined(); diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index 261de632e7..0ddf49679b 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -46,7 +46,7 @@ module.exports = function (style, options, callback) { options.bearing = style.bearing || 0; options.pitch = style.pitch || 0; - map.load(style); + map.load(style, { defaultStyleCamera: true }); applyOperations(options.operations, function() { map.render(options, function (err, pixels) { |