[node] Use new FileSourceManager interface
This commit is contained in:
@@ -20,25 +20,19 @@
|
||||
#include <mbgl/style/layers/raster_layer.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer.hpp>
|
||||
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/style/image.hpp>
|
||||
#include <mbgl/style/light.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/map_observer.hpp>
|
||||
#include <mbgl/storage/file_source_manager.hpp>
|
||||
#include <mbgl/storage/resource_options.hpp>
|
||||
#include <mbgl/style/image.hpp>
|
||||
#include <mbgl/style/light.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/util/async_request.hpp>
|
||||
#include <mbgl/util/exception.hpp>
|
||||
#include <mbgl/util/premultiply.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
std::shared_ptr<FileSource> FileSource::createPlatformFileSource(const ResourceOptions& options) {
|
||||
return std::make_shared<node_mbgl::NodeFileSource>(reinterpret_cast<node_mbgl::NodeMap*>(options.platformContext()));
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
namespace node_mbgl {
|
||||
|
||||
struct NodeMap::RenderOptions {
|
||||
@@ -197,6 +191,12 @@ void NodeMap::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
|
||||
info.This()->SetInternalField(1, options);
|
||||
|
||||
mbgl::FileSourceManager::get()->registerFileSourceFactory(
|
||||
mbgl::FileSourceType::ResourceLoader, [](const mbgl::ResourceOptions& resourceOptions) {
|
||||
return std::make_unique<node_mbgl::NodeFileSource>(
|
||||
reinterpret_cast<node_mbgl::NodeMap*>(resourceOptions.platformContext()));
|
||||
});
|
||||
|
||||
try {
|
||||
auto nodeMap = new NodeMap(options);
|
||||
nodeMap->Wrap(info.This());
|
||||
@@ -1455,4 +1455,8 @@ std::unique_ptr<mbgl::AsyncRequest> NodeFileSource::request(const mbgl::Resource
|
||||
return asyncRequest;
|
||||
}
|
||||
|
||||
bool NodeFileSource::canRequest(const mbgl::Resource&) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace node_mbgl
|
||||
|
||||
Reference in New Issue
Block a user