Support bearing in path overlays

This commit is contained in:
Petr Sloup 2016-06-27 07:42:38 +02:00
parent 900ca4ed3e
commit 2d2c43aeb5

View file

@ -353,7 +353,14 @@ module.exports = function(options, repo, params, id) {
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
var center = precisePx([x, y], z); var center = precisePx([x, y], z);
ctx.scale(scale, scale); ctx.scale(scale, scale);
ctx.translate(-center[0] + w / 2, -center[1] + h / 2); if (bearing) {
ctx.translate(w / 2, h / 2);
ctx.rotate(-bearing / 180 * Math.PI);
ctx.translate(-center[0], -center[1]);
} else {
// optimized path
ctx.translate(-center[0] + w / 2, -center[1] + h / 2);
}
var lineWidth = query.width !== undefined ? var lineWidth = query.width !== undefined ?
parseFloat(query.width) : 1; parseFloat(query.width) : 1;
ctx.lineWidth = lineWidth; ctx.lineWidth = lineWidth;