summaryrefslogtreecommitdiff
path: root/platform/node
diff options
context:
space:
mode:
Diffstat (limited to 'platform/node')
-rw-r--r--platform/node/src/node_map.cpp12
-rw-r--r--platform/node/src/node_map.hpp2
2 files changed, 14 insertions, 0 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index f737ddfd86..a586b11804 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -30,6 +30,7 @@ struct NodeMap::RenderOptions {
unsigned int height = 512;
std::vector<std::string> classes;
mbgl::MapDebugOptions debugOptions = mbgl::MapDebugOptions::NoDebug;
+ std::string id;
};
Nan::Persistent<v8::Function> NodeMap::constructor;
@@ -201,6 +202,10 @@ void NodeMap::Load(const Nan::FunctionCallbackInfo<v8::Value>& info) {
return Nan::ThrowTypeError("First argument must be a string or object");
}
+ if (info[1]->IsString()) {
+ nodeMap->id = *Nan::Utf8String(info[1]);
+ }
+
try {
nodeMap->map->setStyleJSON(style);
} catch (const std::exception &ex) {
@@ -299,6 +304,10 @@ NodeMap::RenderOptions NodeMap::ParseOptions(v8::Local<v8::Object> obj) {
}
}
+ if (Nan::Has(obj, Nan::New("id").ToLocalChecked()).FromJust()) {
+ options.id = std::string { *Nan::Utf8String(Nan::Get(obj, Nan::New("id").ToLocalChecked()).ToLocalChecked()) };
+ }
+
return options;
}
@@ -340,6 +349,8 @@ void NodeMap::Render(const Nan::FunctionCallbackInfo<v8::Value>& info) {
auto options = ParseOptions(Nan::To<v8::Object>(info[0]).ToLocalChecked());
+ if (options.id.length()) nodeMap->id = options.id;
+
assert(!nodeMap->callback);
assert(!nodeMap->image.data);
nodeMap->callback = std::make_unique<Nan::Callback>(info[1].As<v8::Function>());
@@ -771,6 +782,7 @@ std::unique_ptr<mbgl::AsyncRequest> NodeMap::request(const mbgl::Resource& resou
Nan::Set(instance, Nan::New("url").ToLocalChecked(), Nan::New(resource.url).ToLocalChecked());
Nan::Set(instance, Nan::New("kind").ToLocalChecked(), Nan::New<v8::Integer>(resource.kind));
+ Nan::Set(instance, Nan::New("id").ToLocalChecked(), Nan::New(this->id).ToLocalChecked());
auto request = Nan::ObjectWrap::Unwrap<NodeRequest>(instance);
request->Execute();
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp
index 3673b5f2ba..f9e6848432 100644
--- a/platform/node/src/node_map.hpp
+++ b/platform/node/src/node_map.hpp
@@ -60,6 +60,8 @@ public:
uv_async_t *async;
bool loaded = false;
+
+ std::string id;
};
}