Open plepe opened 5 years ago
One big problem is browser support for rotated text on textpath.
You can check how your browser behaves (first image) and compare with screenshots of other browser on this test page: https://xover.mud.at/~skunk/svg-rotate-glyph
Please submit screenshots of other browsers!
I guess I should implement a browser detection and mitigate problems (e.g. select a fixed-width font on firefox, disable rotation on IE/Edge).
Love this! Really hope it can get merged in soon 👍 If it helps, here is screenshot of the above website in Safari 12 on macOS Mojave:
Oh no, Safari does not seem to support textpath at all!
Do you see airplanes, labels and other markers on this webpage? https://makinacorpus.github.io/Leaflet.TextPath/
Apparently there seems to be a bug in Safari: https://stackoverflow.com/questions/50937985/text-within-svg-textpath-not-visible-from-ios-browsers
I can see the aircraft and other markers fine in safari:
That looks okay. I'll try to get my hands on a Mac soon, so I can test what's wrong with my test page ...
Just cloned your fork and ran it on Safari. Everything seems to be fine apart from the turnText and orientation. Unfortunately I don't really know anything about SVG elements otherwise I'd try and fix it:
~~@plepe Thanks for the new options! I tried orientation:'auto' but getting multiple errors:
Error:
@plepe Thanks for the new options! I tried orientation:'auto' but getting multiple errors: Error: attribute transform: Expected number, "rotate(auto 0 0)". Error: attribute transform: Expected number, "rotate(auto 489.8046875…"
Oh. Hard to tell what is the problem without knowing further details. Could you create a test case?
Sorry @plepe. That was my error. Didn't refresh. Please ignore that error.
Good job! Thank you. I ran into one issue with the text not centering as expected, but otherwise super happy e-w text is displaying nicely now. As a fix I can propose the following solution, but I'm new here so I'll leave the final solution up to you.
Change line 109
from
if (!options.allowCrop) {
to
if (!options.allowCrop || options.center) {
Thanks :-) The biggest problem right now is the browser incompatibilities. It will be necessary to implement some kind of switch, which mode to choose:
See: https://xover.mud.at/~skunk/svg-rotate-glyph/ (the relevant line is the "textpath with rotate=180" line)
(Safari also needs the deprecated 'xlink:' prefix when referencing the path)
I have a christmas present for you!
I would have liked to create pull requests for each feature, but they all depend on each other, that's why I created a "features" pull request.
It includes the following features:
repeat
as float to set the distance between each repetition in pixels (will be approximated by spaces). Replaces #70 .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). This could improve performance on maps with short lines.text
parameter. Fixes #26 . (See the "Rainbow" in the screenshot below)turnedText
: When flipping a label because of orientationauto
(for east-west line parts), use this text instead. Useful if a label includes directional characters like arrows.Also:
Tell me what you think about it.