[node] Fix order of operations when setting zoom and center
Zoom must be set first, to avoid center potentially getting constrained. Fixes #7351
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#66397c8ee0426537d25e8d4cfcac134ca21a021b",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-cmake": "^1.2.1",
|
||||
"pixelmatch": "^4.0.2",
|
||||
"pngjs": "^3.0.0",
|
||||
"request": "^2.72.0",
|
||||
"tape": "^4.5.1"
|
||||
},
|
||||
|
||||
@@ -371,15 +371,15 @@ void NodeMap::startRender(NodeMap::RenderOptions options) {
|
||||
map->setClasses(options.classes);
|
||||
}
|
||||
|
||||
if (map->getZoom() != options.zoom) {
|
||||
map->setZoom(options.zoom);
|
||||
}
|
||||
|
||||
mbgl::LatLng latLng(options.latitude, options.longitude);
|
||||
if (map->getLatLng() != latLng) {
|
||||
map->setLatLng(latLng);
|
||||
}
|
||||
|
||||
if (map->getZoom() != options.zoom) {
|
||||
map->setZoom(options.zoom);
|
||||
}
|
||||
|
||||
if (map->getBearing() != options.bearing) {
|
||||
map->setBearing(options.bearing);
|
||||
}
|
||||
|
||||
BIN
platform/node/test/fixtures/zoom-center/expected.png
vendored
Normal file
BIN
platform/node/test/fixtures/zoom-center/expected.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 882 B |
@@ -371,6 +371,48 @@ test('Map', function(t) {
|
||||
map.release();
|
||||
t.end();
|
||||
});
|
||||
|
||||
// This can't be tested with a test-suite render test because zoom and center
|
||||
// are set via a different code path when included as style properties.
|
||||
t.test('sets zoom before center', function(t) {
|
||||
var map = new mbgl.Map(options);
|
||||
map.load({
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"geojson": {
|
||||
"type": "geojson",
|
||||
"data": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
18.05489,
|
||||
59.32744
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"layers": [
|
||||
{
|
||||
"id": "circle",
|
||||
"type": "circle",
|
||||
"source": "geojson",
|
||||
"paint": {
|
||||
"circle-color": "red"
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
map.render({width: 400, height: 400, zoom: 5, center: [18.05489, 59.32744]}, function(err, actual) {
|
||||
t.error(err);
|
||||
|
||||
var PNG = require('pngjs').PNG;
|
||||
var pixelmatch = require('pixelmatch');
|
||||
var expected = PNG.sync.read(
|
||||
fs.readFileSync(path.join(__dirname, '../fixtures/zoom-center/expected.png'))).data;
|
||||
var numPixels = pixelmatch(actual, expected, undefined, 400, 400, { threshold: 0.13 });
|
||||
t.equal(numPixels, 0);
|
||||
t.end();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
t.test('request callback', function (t) {
|
||||
|
||||
Reference in New Issue
Block a user