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);
|
||||
|
||||
Reference in New Issue
Block a user