-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flip upside down text on right to left lines...? #26
Comments
There is no built-in or automatic way to do this. |
Thanks for the quick reply. I'm guessing that the way to go would be to work out the line's direction, then do a label transform based on the result (i.e. only labels on lines that head east are flipped?) Here's some code to determine a (very rough) line direction (N, E, S or W) https://raw.githubusercontent.com/kirkau/leaflet.GISTools/master/generalLineDirection.js I'm not well versed in SVG... you may be able to get to the next step much more quickly than I can? maybe something like if (getGeneralDirection(getBearing(lat1,lon1,lat2,lon2)) == "E") { I'm putting text and an arrow in the label. The arrow is in the correct direction - it's just the text that needs correcting, so may run into problems rotating the whole string? Are you able to attach two strings to a line? Cheers |
I guess you can find some hints here http://tutorials.jenkov.com/svg/text-element.html#rotating-text
Could you reproduce a small example in a jsfiddle or similar so that we can give a look ? If you use the arrow feature of this plugin, it won't be a problem since it relies on line endings and not proper text... |
Cheers for the link. I've made a patch and submitted a PR
I'd like to integrate the directional check and also perhaps provide a specific rotation angle/allow for perpendicular labels. Any input on structure? I've linked bearing and direction code above... |
sorry should have been textNode.setAttribute('transform', 'rotate(180 ' + rotatecenterX + ' ' + rotatecenterY + ')'); copied the wrong text block :( |
Well, you can add an option with the rotation angle... If you'd like to keep your previous PR it could become :
If you add some code for the bearing/directional check, make sure it remains super easy to use. IHMO it should remain internal stuff. |
This would be very useful! |
Well, since this is still open, here's an approach I've been trying
|
Is there any way to flip the text when the line runs left to right (so it isn't upside down?)
cheers
The text was updated successfully, but these errors were encountered: