MCPcopy
hub / github.com/python-visualization/folium / Tooltip

Class Tooltip

folium/map.py:594–647  ·  view source on GitHub ↗

Create a tooltip that shows text when hovering over its parent object. Parameters ---------- text: str String to display as a tooltip on the object. If the argument is of a different type it will be converted to str. style: str, default None. HTML inline

Source from the content-addressed store, hash-verified

592
593
594class Tooltip(MacroElement):
595 """
596 Create a tooltip that shows text when hovering over its parent object.
597
598 Parameters
599 ----------
600 text: str
601 String to display as a tooltip on the object. If the argument is of a
602 different type it will be converted to str.
603 style: str, default None.
604 HTML inline style properties like font and colors. Will be applied to
605 a div with the text in it.
606 sticky: bool, default True
607 Whether the tooltip should follow the mouse.
608 **kwargs
609 These values will map directly to the Leaflet Options. More info
610 available here: https://leafletjs.com/reference.html#tooltip
611
612 """
613
614 _template = Template(
615 """
616 {% macro script(this, kwargs) %}
617 {{ this._parent.get_name() }}.bindTooltip(
618 `<div{% if this.style %} style={{ this.style|tojson }}{% endif %}>
619 {{ this.text }}
620 </div>`,
621 {{ this.options|tojavascript }}
622 );
623 {% endmacro %}
624 """
625 )
626
627 def __init__(
628 self,
629 text: str,
630 style: Optional[str] = None,
631 sticky: bool = True,
632 **kwargs: TypeJsonValue,
633 ):
634 super().__init__()
635 self._name = "Tooltip"
636
637 self.text = str(text)
638
639 kwargs.update({"sticky": sticky})
640 self.options = remove_empty(**kwargs)
641
642 if style:
643 assert isinstance(
644 style, str
645 ), "Pass a valid inline HTML style property string to style."
646 # noqa outside of type checking.
647 self.style = style
648
649
650class FitBounds(MacroElement):

Callers 5

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.85

Calls 1

TemplateClass · 0.90

Tested by

no test coverage detected