diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-10 21:17:58 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-13 17:22:05 -0700 |
commit | 3f5ea169f5d617455b21467fbd12a812c6aa2972 (patch) | |
tree | 63163d4ba45f7a88b6c7bb6cc681d9eda16ec868 /platform/node/test | |
parent | 6cc2f8a3a52d0c375458c7da4fe51e8160e38a88 (diff) | |
download | qtlocation-mapboxgl-3f5ea169f5d617455b21467fbd12a812c6aa2972.tar.gz |
[node] Partial implementation of runtime styling API for node bindings
Diffstat (limited to 'platform/node/test')
-rw-r--r-- | platform/node/test/suite_implementation.js | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index da226a68f4..4369c81ffc 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -41,16 +41,39 @@ module.exports = function (style, options, callback) { map.load(style); - map.render(options, function (err, pixels) { - var results = options.queryGeometry ? - map.queryRenderedFeatures(options.queryGeometry) : - []; - map.release(); - if (timedOut) return; - clearTimeout(watchdog); - callback(err, pixels, results.map(prepareFeatures)); + applyOperations(options.operations, function() { + map.render(options, function (err, pixels) { + var results = options.queryGeometry ? + map.queryRenderedFeatures(options.queryGeometry) : + []; + map.release(); + if (timedOut) return; + clearTimeout(watchdog); + callback(err, pixels, results.map(prepareFeatures)); + }); }); + function applyOperations(operations, callback) { + var operation = operations && operations[0]; + if (!operations || operations.length === 0) { + callback(); + + } else if (operation[0] === 'wait') { + var wait = function() { + if (map.loaded()) { + applyOperations(operations.slice(1), callback); + } else { + map.render(options, wait); + } + }; + wait(); + + } else { + map[operation[0]].apply(map, operation.slice(1)); + applyOperations(operations.slice(1), callback); + } + } + function prepareFeatures(r) { delete r.layer; return r; |