Skip to content

Commit

Permalink
Look the other way when placing icon at start of line
Browse files Browse the repository at this point in the history
When an anchor is at the beginning of a line, its segment’s coordinates match its own coordinates, resulting in an angle of 0°. When the segment’s coordinates match the anchor’s coordinates, consider the next segment instead.

ref #1461
  • Loading branch information
1ec5 authored and mourner committed Oct 8, 2015
1 parent 7fd961a commit 739aa39
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/symbol/quads.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ function getIconQuads(anchor, shapedIcon, boxScale, line, layout, alongLine) {
var angle = layout['icon-rotate'] * Math.PI / 180;
if (alongLine) {
var prev = line[anchor.segment];
angle += Math.atan2(anchor.y - prev.y, anchor.x - prev.x);
if (anchor.y === prev.y && anchor.x === prev.x && anchor.segment + 1 < line.length) {
var next = line[anchor.segment + 1];
angle += Math.atan2(anchor.y - next.y, anchor.x - next.x) + Math.PI;
} else {
angle += Math.atan2(anchor.y - prev.y, anchor.x - prev.x);
}
}

if (angle) {
Expand Down

0 comments on commit 739aa39

Please sign in to comment.