From 8e6a1711d016cc3d2c7ed0eba46ddb81e7d3212f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 23 Dec 2018 22:09:21 +0100 Subject: [PATCH] Use same code as orientation=auto for orientation=flip fixes #71 --- README.md | 2 +- leaflet.textpath.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 207ce42..9ed4f5b 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ The `text` parameter of `setText()` can either be: * `offset` Set an offset to position text relative to the polyline (Default: 0) * `orientation` Rotate text. (Default: 0) - {orientation: angle} - rotate to a specified angle (e.g. {orientation: 15}) - - {orientation: flip} - filps the text 180deg correction for upside down text placement on west -> east lines + - {orientation: flip} - flips the text 180deg correction for upside down text placement on west -> east lines - {orientation: perpendicular} - places text at right angles to the line. - {orientation: auto} - flips the text on (part of) ways running west to east, so that they are readable upside down. * `allowCrop` If the line is too short to display the whole text, crop the text. If false, don't show the text at all. (Default: true). diff --git a/leaflet.textpath.js b/leaflet.textpath.js index cc97263..c4a81c5 100755 --- a/leaflet.textpath.js +++ b/leaflet.textpath.js @@ -140,11 +140,13 @@ var PolylineTextPath = { } else { finalText.push({ text: turnText(text), rotate: 180 }); } + } else if (options.orientation === 'flip') { + finalText.push({ text: turnText(text), rotate: 180 }); } else { finalText = [ text ]; } } else { - if (options.orientation === 'auto') { + if (options.orientation === 'auto' || options.orientation === 'flip') { var textTurned = turnText(text) } @@ -190,6 +192,8 @@ var PolylineTextPath = { } else { finalText.push({ text: textTurned, rotate: 180 }); } + } else if (options.orientation === 'flip') { + finalText.push({ text: textTurned, rotate: 180 }); } else { finalText.push(text); } @@ -227,13 +231,11 @@ var PolylineTextPath = { if (options.orientation) { var rotateAngle = 0; switch (options.orientation) { - case 'flip': - rotateAngle = 180; - break; case 'perpendicular': rotateAngle = 90; break; case 'auto': + case 'flip': rotateAngle = 0; break; default: