Throw when style is not loaded
mbgl::Map won't throw if the style is not set but we can track that on NodeMap.
This commit is contained in:
@@ -102,6 +102,10 @@ NAN_METHOD(NodeMap::Load) {
|
||||
|
||||
if (!nodeMap->isValid()) return NanThrowError(releasedMessage());
|
||||
|
||||
// Reset the flag as this could be the second time
|
||||
// we are calling this (being the previous successful).
|
||||
nodeMap->loaded = false;
|
||||
|
||||
if (args.Length() < 1) {
|
||||
return NanThrowError("Requires a map style as first argument");
|
||||
}
|
||||
@@ -122,6 +126,8 @@ NAN_METHOD(NodeMap::Load) {
|
||||
return NanThrowError(ex.what());
|
||||
}
|
||||
|
||||
nodeMap->loaded = true;
|
||||
|
||||
NanReturnUndefined();
|
||||
}
|
||||
|
||||
@@ -168,6 +174,10 @@ NAN_METHOD(NodeMap::Render) {
|
||||
return NanThrowTypeError("Second argument must be a callback function");
|
||||
}
|
||||
|
||||
if (!nodeMap->isLoaded()) {
|
||||
return NanThrowTypeError("Style is not loaded");
|
||||
}
|
||||
|
||||
auto options = ParseOptions(args[0]->ToObject());
|
||||
|
||||
assert(!nodeMap->callback);
|
||||
|
||||
@@ -33,6 +33,8 @@ public:
|
||||
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);
|
||||
@@ -60,6 +62,7 @@ private:
|
||||
// Async for delivering the notifications of render completion.
|
||||
uv_async_t *async;
|
||||
|
||||
bool loaded = false;
|
||||
bool valid = true;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user