Shows a text along a PolyLine. Parameters ---------- polyline: folium.features.PolyLine object The folium.features.PolyLine object to attach the text to. text: string The string to be attached to the polyline. repeat: bool, default False Specifies if
| 5 | |
| 6 | |
| 7 | class PolyLineTextPath(JSCSSMixin, MacroElement): |
| 8 | """ |
| 9 | Shows a text along a PolyLine. |
| 10 | |
| 11 | Parameters |
| 12 | ---------- |
| 13 | polyline: folium.features.PolyLine object |
| 14 | The folium.features.PolyLine object to attach the text to. |
| 15 | text: string |
| 16 | The string to be attached to the polyline. |
| 17 | repeat: bool, default False |
| 18 | Specifies if the text should be repeated along the polyline. |
| 19 | center: bool, default False |
| 20 | Centers the text according to the polyline's bounding box |
| 21 | below: bool, default False |
| 22 | Show text below the path |
| 23 | offset: int, default 0 |
| 24 | Set an offset to position text relative to the polyline. |
| 25 | orientation: int, default 0 |
| 26 | Rotate text to a specified angle. |
| 27 | attributes: dict |
| 28 | Object containing the attributes applied to the text tag. |
| 29 | Check valid attributes here: |
| 30 | https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text#attributes |
| 31 | Example: {'fill': '#007DEF', 'font-weight': 'bold', 'font-size': '24'} |
| 32 | |
| 33 | See https://github.com/makinacorpus/Leaflet.TextPath for more information. |
| 34 | |
| 35 | """ |
| 36 | |
| 37 | _template = Template( |
| 38 | """ |
| 39 | {% macro script(this, kwargs) %} |
| 40 | {{ this.polyline.get_name() }}.setText( |
| 41 | {{ this.text|tojson }}, |
| 42 | {{ this.options|tojavascript }} |
| 43 | ); |
| 44 | {% endmacro %} |
| 45 | """ |
| 46 | ) |
| 47 | |
| 48 | default_js = [ |
| 49 | ( |
| 50 | "polylinetextpath", |
| 51 | "https://cdn.jsdelivr.net/npm/leaflet-textpath@1.2.3/leaflet.textpath.min.js", |
| 52 | ) |
| 53 | ] |
| 54 | |
| 55 | def __init__( |
| 56 | self, |
| 57 | polyline, |
| 58 | text, |
| 59 | repeat=False, |
| 60 | center=False, |
| 61 | below=False, |
| 62 | offset=0, |
| 63 | orientation=0, |
| 64 | attributes=None, |
nothing calls this directly
no test coverage detected
searching dependent graphs…