require 'ratio' in mbgl.Map options, mbgl::Update::Dimensions in main thread
This commit is contained in:
@@ -66,7 +66,7 @@ NAN_METHOD(NodeMap::New) {
|
||||
|
||||
auto options = args[0]->ToObject();
|
||||
|
||||
// Check that request() and cancel() are defined.
|
||||
// Check that 'request', 'cancel' and 'ratio' are defined.
|
||||
if (!options->Has(NanNew("request")) || !options->Get(NanNew("request"))->IsFunction()) {
|
||||
return NanThrowError("Options object must have a 'request' method");
|
||||
}
|
||||
@@ -74,6 +74,10 @@ NAN_METHOD(NodeMap::New) {
|
||||
return NanThrowError("Options object 'cancel' property must be a function");
|
||||
}
|
||||
|
||||
if (!options->Has(NanNew("ratio")) || !options->Get(NanNew("ratio"))->IsNumber()) {
|
||||
return NanThrowError("Options object must have a numerical 'ratio' property");
|
||||
}
|
||||
|
||||
try {
|
||||
auto nodeMap = new NodeMap(options);
|
||||
nodeMap->Wrap(args.This());
|
||||
@@ -193,6 +197,7 @@ NAN_METHOD(NodeMap::Render) {
|
||||
|
||||
void NodeMap::startRender(std::unique_ptr<NodeMap::RenderOptions> options) {
|
||||
view.resize(options->width, options->height);
|
||||
map->update(mbgl::Update::Dimensions);
|
||||
map->setClasses(options->classes);
|
||||
map->setLatLngZoom(mbgl::LatLng(options->latitude, options->longitude), options->zoom);
|
||||
map->setBearing(options->bearing);
|
||||
@@ -319,7 +324,7 @@ void NodeMap::release() {
|
||||
// Instance
|
||||
|
||||
NodeMap::NodeMap(v8::Handle<v8::Object> options) :
|
||||
view(sharedDisplay(), 1.0),
|
||||
view(sharedDisplay(), options->Get(NanNew("ratio"))->NumberValue()),
|
||||
fs(options),
|
||||
map(std::make_unique<mbgl::Map>(view, fs, mbgl::MapMode::Still)),
|
||||
async(new uv_async_t) {
|
||||
|
||||
@@ -24,6 +24,7 @@ function renderTest(style, info, dir, key) {
|
||||
});
|
||||
};
|
||||
options.cancel = function() {};
|
||||
options.ratio = 1.0;
|
||||
|
||||
var map = new mbgl.Map(options);
|
||||
map.load(style);
|
||||
@@ -50,7 +51,7 @@ function rewriteLocalSchema(uri) {
|
||||
return uri.replace(/^local:\/\//, '');
|
||||
}
|
||||
|
||||
test('Concurrency', function(t) {
|
||||
test('Consecutive', function(t) {
|
||||
var dir = 'line-join';
|
||||
var k = 'round';
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ function getOptions(gzip, t) {
|
||||
response.data = res.body;
|
||||
req.respond(null, response);
|
||||
});
|
||||
}
|
||||
},
|
||||
ratio: 1.0
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,16 @@ test('Map', function(t) {
|
||||
}, /Options object 'cancel' property must be a function/);
|
||||
|
||||
options.cancel = function() {};
|
||||
t.throws(function() {
|
||||
new mbgl.Map(options);
|
||||
}, /Options object must have a numerical 'ratio' property/);
|
||||
|
||||
options.ratio = 'test';
|
||||
t.throws(function() {
|
||||
new mbgl.Map(options);
|
||||
}, /Options object must have a numerical 'ratio' property/);
|
||||
|
||||
options.ratio = 1.0;
|
||||
t.doesNotThrow(function() {
|
||||
new mbgl.Map(options);
|
||||
});
|
||||
@@ -79,6 +89,7 @@ test('Map', function(t) {
|
||||
var options = {};
|
||||
options.request = function() {};
|
||||
options.cancel = function() {};
|
||||
options.ratio = 1.0;
|
||||
|
||||
t.test('requires a string or object as the first parameter', function(t) {
|
||||
t.test('requires a map style as first argument', function(t) {
|
||||
@@ -159,6 +170,7 @@ test('Map', function(t) {
|
||||
});
|
||||
};
|
||||
options.cancel = function() {};
|
||||
options.ratio = 1.0;
|
||||
|
||||
t.test('requires an object as the first parameter', function(t) {
|
||||
setup(options, function(map) {
|
||||
|
||||
@@ -47,6 +47,7 @@ function renderTest(style, info, base, key) {
|
||||
});
|
||||
};
|
||||
options.cancel = function() {};
|
||||
options.ratio = 1.0;
|
||||
|
||||
var map = new mbgl.Map(options);
|
||||
map.load(style);
|
||||
|
||||
2
vendor/mbgl
vendored
2
vendor/mbgl
vendored
Submodule vendor/mbgl updated: b5f918af7c...5d038fbd84
Reference in New Issue
Block a user