Represents a lightweight icon for markers that uses a simple `div` element instead of an image. Parameters ---------- icon_size : tuple of 2 int Size of the icon image in pixels. icon_anchor : tuple of 2 int The coordinates of the "tip" of the icon (
| 1718 | |
| 1719 | |
| 1720 | class DivIcon(MacroElement): |
| 1721 | """ |
| 1722 | Represents a lightweight icon for markers that uses a simple `div` |
| 1723 | element instead of an image. |
| 1724 | |
| 1725 | Parameters |
| 1726 | ---------- |
| 1727 | icon_size : tuple of 2 int |
| 1728 | Size of the icon image in pixels. |
| 1729 | icon_anchor : tuple of 2 int |
| 1730 | The coordinates of the "tip" of the icon |
| 1731 | (relative to its top left corner). |
| 1732 | The icon will be aligned so that this point is at the |
| 1733 | marker's geographical location. |
| 1734 | popup_anchor : tuple of 2 int |
| 1735 | The coordinates of the point from which popups will "open", |
| 1736 | relative to the icon anchor. |
| 1737 | class_name : string |
| 1738 | A custom class name to assign to the icon. |
| 1739 | Leaflet defaults is 'leaflet-div-icon' which draws a little white |
| 1740 | square with a shadow. We set it 'empty' in folium. |
| 1741 | html : string |
| 1742 | A custom HTML code to put inside the div element. |
| 1743 | |
| 1744 | See https://leafletjs.com/reference.html#divicon |
| 1745 | |
| 1746 | """ |
| 1747 | |
| 1748 | _template = Template( |
| 1749 | """ |
| 1750 | {% macro script(this, kwargs) %} |
| 1751 | var {{ this.get_name() }} = L.divIcon({{ this.options|tojavascript }}); |
| 1752 | {% endmacro %} |
| 1753 | """ |
| 1754 | ) # noqa |
| 1755 | |
| 1756 | def __init__( |
| 1757 | self, |
| 1758 | html: Optional[str] = None, |
| 1759 | icon_size: Optional[Tuple[int, int]] = None, |
| 1760 | icon_anchor: Optional[Tuple[int, int]] = None, |
| 1761 | popup_anchor: Optional[Tuple[int, int]] = None, |
| 1762 | class_name: str = "empty", |
| 1763 | ): |
| 1764 | super().__init__() |
| 1765 | self._name = "DivIcon" |
| 1766 | self.options = remove_empty( |
| 1767 | html=html, |
| 1768 | icon_size=icon_size, |
| 1769 | icon_anchor=icon_anchor, |
| 1770 | popup_anchor=popup_anchor, |
| 1771 | class_name=class_name, |
| 1772 | ) |
| 1773 | |
| 1774 | |
| 1775 | class LatLngPopup(MacroElement): |
nothing calls this directly
no test coverage detected
searching dependent graphs…