#pragma once #include #include #include #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wshadow" #include #pragma GCC diagnostic pop namespace mbgl { class HeadlessFrontend; } // namespace mbgl namespace node_mbgl { struct NodeMapObserver : public mbgl::MapObserver { void onDidFailLoadingMap(mbgl::MapLoadError, const std::string&) final; }; class RenderRequest; class NodeMap : public Nan::ObjectWrap { public: struct RenderOptions; class RenderWorker; NodeMap(v8::Local); ~NodeMap(); static Nan::Persistent constructor; static Nan::Persistent parseError; static void Init(v8::Local); static void New(const Nan::FunctionCallbackInfo&); static void Load(const Nan::FunctionCallbackInfo&); static void Loaded(const Nan::FunctionCallbackInfo&); static void Render(const Nan::FunctionCallbackInfo&); static void Release(const Nan::FunctionCallbackInfo&); static void Cancel(const Nan::FunctionCallbackInfo&); static void AddSource(const Nan::FunctionCallbackInfo&); static void RemoveSource(const Nan::FunctionCallbackInfo&); static void AddLayer(const Nan::FunctionCallbackInfo&); static void RemoveLayer(const Nan::FunctionCallbackInfo&); static void AddImage(const Nan::FunctionCallbackInfo&); static void RemoveImage(const Nan::FunctionCallbackInfo&); static void SetLayerZoomRange(const Nan::FunctionCallbackInfo&); static void SetLayerProperty(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 SetLight(const Nan::FunctionCallbackInfo&); static void SetAxonometric(const Nan::FunctionCallbackInfo&); static void SetXSkew(const Nan::FunctionCallbackInfo&); static void SetYSkew(const Nan::FunctionCallbackInfo&); static void DumpDebugLogs(const Nan::FunctionCallbackInfo&); static void QueryRenderedFeatures(const Nan::FunctionCallbackInfo&); static void SetFeatureState(const Nan::FunctionCallbackInfo&); static void GetFeatureState(const Nan::FunctionCallbackInfo&); static void RemoveFeatureState(const Nan::FunctionCallbackInfo&); static v8::Local ParseError(const char* msg); void startRender(RenderOptions options); void renderFinished(); void release(); void cancel(); static RenderOptions ParseOptions(v8::Local); const float pixelRatio; mbgl::MapMode mode; bool crossSourceCollisions; NodeMapObserver mapObserver; std::unique_ptr frontend; std::unique_ptr map; std::exception_ptr error; mbgl::PremultipliedImage image; std::unique_ptr req; // Async for delivering the notifications of render completion. uv_async_t *async; bool loaded = false; }; struct NodeFileSource : public mbgl::FileSource { NodeFileSource(NodeMap* nodeMap_) : nodeMap(nodeMap_) {} ~NodeFileSource() {} std::unique_ptr request(const mbgl::Resource&, mbgl::FileSource::Callback) final; bool canRequest(const mbgl::Resource&) const override; NodeMap* nodeMap; }; } // namespace node_mbgl