Skip to content

Commit

Permalink
Inherit default value of text-pitch-alignment from text-rotation-alig…
Browse files Browse the repository at this point in the history
…nment.
  • Loading branch information
yhahn committed Jun 10, 2016
1 parent a9afa72 commit e93f91e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
3 changes: 3 additions & 0 deletions js/style/style_layer/symbol_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ SymbolStyleLayer.prototype = util.inherit(StyleLayer, {
this.getLayoutValue('symbol-placement', globalProperties, featureProperties) === 'line' &&
!this.getLayoutProperty('icon-rotation-alignment')) {
return 'map';
// If unspecified `text-pitch-alignment` inherits `text-rotation-alignment`
} else if (name === 'text-pitch-alignment' && !this.getLayoutProperty('text-pitch-alignment')) {
return this.getLayoutValue('text-rotation-alignment');
} else {
return StyleLayer.prototype.getLayoutValue.apply(this, arguments);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"mapbox-gl-function": "^1.2.1",
"mapbox-gl-js-supported": "^1.1.0",
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#adcc18ad79b363ff17443d746d26c2ecee6bcb5e",
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#586dbf48f7ebd79ed623c5ad809a564013173acf",
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#2461efc3d883f2f2e56a6c6b2bfd7d54bbfe9f86",
"minifyify": "^7.0.1",
"pbf": "^1.3.2",
"pngjs": "^2.2.0",
Expand Down
60 changes: 60 additions & 0 deletions test/js/style/style_layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,66 @@ test('StyleLayer#serialize', function(t) {
t.end();
});

test('StyleLayer#getLayoutValue (default exceptions)', function(assert) {
assert.test('symbol-placement:point => *-rotation-alignment:viewport', function(assert) {
var layer = StyleLayer.create({
"type": "symbol",
"layout": {
"symbol-placement": "point"
}
});
assert.equal(layer.getLayoutValue('text-rotation-alignment'), 'viewport');
assert.equal(layer.getLayoutValue('icon-rotation-alignment'), 'viewport');
assert.end();
});
assert.test('symbol-placement:line => *-rotation-alignment:map', function(assert) {
var layer = StyleLayer.create({
"type": "symbol",
"layout": {
"symbol-placement": "line"
}
});
assert.equal(layer.getLayoutValue('text-rotation-alignment'), 'map');
assert.equal(layer.getLayoutValue('icon-rotation-alignment'), 'map');
assert.end();
});
assert.test('text-rotation-alignment:map => text-pitch-alignment:map', function(assert) {
var layer = StyleLayer.create({
"type": "symbol",
"layout": {
"text-rotation-alignment": "map"
}
});
assert.equal(layer.getLayoutValue('text-rotation-alignment'), 'map');
assert.equal(layer.getLayoutValue('text-pitch-alignment'), 'map');
assert.end();
});
assert.test('text-rotation-alignment:viewport => text-pitch-alignment:viewport', function(assert) {
var layer = StyleLayer.create({
"type": "symbol",
"layout": {
"text-rotation-alignment": "viewport"
}
});
assert.equal(layer.getLayoutValue('text-rotation-alignment'), 'viewport');
assert.equal(layer.getLayoutValue('text-pitch-alignment'), 'viewport');
assert.end();
});
assert.test('text-pitch-alignment respected when set', function(assert) {
var layer = StyleLayer.create({
"type": "symbol",
"layout": {
"text-rotation-alignment": "viewport",
"text-pitch-alignment": "map"
}
});
assert.equal(layer.getLayoutValue('text-rotation-alignment'), 'viewport');
assert.equal(layer.getLayoutValue('text-pitch-alignment'), 'map');
assert.end();
});
assert.end();
});

function createAnimationLoop() {
return {
set: function() {},
Expand Down

0 comments on commit e93f91e

Please sign in to comment.