diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2015-09-02 15:46:43 -0400 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2015-09-02 15:46:43 -0400 |
commit | 322e1aa2c3c2570554a2fe2bbfa733ab7bbd4e81 (patch) | |
tree | c6d665f13f1342b8a5adaff14a7a676a6b0c4a85 /platform/node/src/node_map.hpp | |
parent | 6929dcec966c5c9eb2f2409fb4568f55253116f9 (diff) | |
parent | 6634adee398c7e84c0892042751fa299546a9965 (diff) | |
download | qtlocation-mapboxgl-322e1aa2c3c2570554a2fe2bbfa733ab7bbd4e81.tar.gz |
Merge pull request #2179 from mapbox/node
Node bindings
Diffstat (limited to 'platform/node/src/node_map.hpp')
-rw-r--r-- | platform/node/src/node_map.hpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp new file mode 100644 index 0000000000..2c87900d4d --- /dev/null +++ b/platform/node/src/node_map.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include "node_file_source.hpp" + +#include <mbgl/map/map.hpp> +#include <mbgl/platform/default/headless_view.hpp> + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wshadow" +#include <node.h> +#include <nan.h> +#pragma GCC diagnostic pop + +#include <queue> + +namespace node_mbgl { + +class NodeMap : public node::ObjectWrap { + struct RenderOptions; + class RenderWorker; + + //////////////////////////////////////////////////////////////////////////////////////////////// + // Static Node Methods +public: + static void Init(v8::Handle<v8::Object> target); + static NAN_METHOD(New); + static NAN_METHOD(Load); + static NAN_METHOD(Render); + static NAN_METHOD(Release); + + void startRender(std::unique_ptr<NodeMap::RenderOptions> options); + void renderFinished(); + + void release(); + + inline bool isLoaded() { return loaded; } + inline bool isValid() { return valid; } + + static std::unique_ptr<NodeMap::RenderOptions> ParseOptions(v8::Local<v8::Object> obj); + + static v8::Persistent<v8::FunctionTemplate> constructorTemplate; + + //////////////////////////////////////////////////////////////////////////////////////////////// + // Instance +private: + NodeMap(v8::Handle<v8::Object>); + ~NodeMap(); + +private: + mbgl::HeadlessView view; + NodeFileSource fs; + std::unique_ptr<mbgl::Map> map; + + std::exception_ptr error; + std::unique_ptr<const mbgl::StillImage> image; + std::unique_ptr<NanCallback> callback; + + // Async for delivering the notifications of render completion. + uv_async_t *async; + + bool loaded = false; + bool valid = true; +}; + +} |