Skip to content

Commit

Permalink
Add visibility property for v7.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Budorick committed Jan 23, 2015
1 parent 8ab5548 commit 0fbfc6d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 4 additions & 0 deletions js/source/worker_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ WorkerTile.prototype.parse = function(data, layers, actor, callback) {
if (maxzoom && this.zoom >= maxzoom)
continue;

var visibility = layer.layout.visibility;
if (visibility === 'none')
continue;

bucket = createBucket(layer, buffers, collision);
bucket.layers = [layer.id];

Expand Down
4 changes: 3 additions & 1 deletion js/style/style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ StyleLayer.prototype = {
}

this.hidden = (this.minzoom && z < this.minzoom) ||
(this.maxzoom && z >= this.maxzoom);
(this.maxzoom && z >= this.maxzoom) ||
// include visibility check for non-bucketed background layers
(this.layout.visibility === 'none');

if (type === 'symbol') {
if ((calculated['text-opacity'] === 0 || !this.layout['text-field']) &&
Expand Down
26 changes: 22 additions & 4 deletions test/js/source/worker_tile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test('basic', function(t) {
id: 'test',
source: 'source',
type: 'fill',
layout: {},
compare: function () { return true; }
}];

Expand All @@ -19,9 +20,26 @@ test('basic', function(t) {
}];

var tile = new WorkerTile('', 0, 20, 512, 'source', 1);
tile.parse(new Wrapper(features), buckets, {}, function(err, result) {
t.ok(result.buffers, 'buffers');
t.ok(result.elementGroups, 'element groups');
t.end();

t.test('basic worker tile', function(t) {
tile.parse(new Wrapper(features), buckets, {}, function(err, result) {
t.ok(result.buffers, 'buffers');
t.ok(result.elementGroups, 'element groups');
t.end();
});
});

t.test('hidden layers', function(t) {
buckets.push({
id: 'test-hidden',
source: 'source',
type: 'fill',
layout: { visibility: 'none' },
compare: function () { return true; }
});
tile.parse(new Wrapper(features), buckets, {}, function(err, result) {
t.equal(Object.keys(result.elementGroups).length, 1, 'element groups exclude hidden layer');
t.end();
});
});
});

0 comments on commit 0fbfc6d

Please sign in to comment.