Skip to content

Commit

Permalink
Merge pull request #515 from mapbox/icon-rotate
Browse files Browse the repository at this point in the history
Implement icon/text-rotate
  • Loading branch information
mourner committed Jul 7, 2014
2 parents e46712c + 72e0cd0 commit b03a215
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions debug/style-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,9 @@
"render": {
"type": "symbol",
"symbol-placement": "line",
"icon-image": "bicycle-12",
"symbol-min-distance": 150
"symbol-min-distance": 150,
"icon-image": "triangle-stroked-12",
"icon-rotate": 90
},
"style": {}
}]
Expand Down
10 changes: 6 additions & 4 deletions js/render/drawsymbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ function drawSymbol(gl, painter, bucket, layerStyle, posMatrix, params, imageSpr
var info = bucket.info;

var exMatrix = mat4.clone(painter.projectionMatrix);
if (info[prefix + '-rotation-alignment'] === 'map') {
mat4.rotateZ(exMatrix, exMatrix, painter.transform.angle);
var angleOffset = (info[prefix + '-rotation-alignment'] === 'map' ? painter.transform.angle : 0) -
(info[prefix + '-rotate'] || 0) * Math.PI / 180;

if (angleOffset) {
mat4.rotateZ(exMatrix, exMatrix, angleOffset);
}

// If layerStyle.size > info[prefix + '-max-size'] then labels may collide
Expand All @@ -49,8 +52,7 @@ function drawSymbol(gl, painter, bucket, layerStyle, posMatrix, params, imageSpr
buffer = bucket.buffers.glyphVertex;
texsize = [painter.glyphAtlas.width, painter.glyphAtlas.height];
} else {
var rotate = info[prefix + '-rotation-alignment'] === 'map';
imageSprite.bind(gl, rotate || params.rotating || params.zooming);
imageSprite.bind(gl, angleOffset || params.rotating || params.zooming);
buffer = bucket.buffers.iconVertex;
texsize = [imageSprite.img.width, imageSprite.img.height];
}
Expand Down

0 comments on commit b03a215

Please sign in to comment.