MCPcopy Create free account
hub / github.com/python-visualization/folium / CustomIcon

Class CustomIcon

folium/features.py:1889–1952  ·  view source on GitHub ↗

Create a custom icon, based on an image. Parameters ---------- icon_image : string or array-like object The data to use as an icon. * If string is a path to an image file, its content will be converted and embedded. * If string is a URL, it will b

Source from the content-addressed store, hash-verified

1887
1888
1889class CustomIcon(Icon):
1890 """
1891 Create a custom icon, based on an image.
1892
1893 Parameters
1894 ----------
1895 icon_image : string or array-like object
1896 The data to use as an icon.
1897
1898 * If string is a path to an image file, its content will be converted and
1899 embedded.
1900 * If string is a URL, it will be linked.
1901 * Otherwise a string will be assumed to be JSON and embedded.
1902 * If array-like, it will be converted to PNG base64 string and embedded.
1903 icon_size : tuple of 2 int, optional
1904 Size of the icon image in pixels.
1905 icon_anchor : tuple of 2 int, optional
1906 The coordinates of the "tip" of the icon
1907 (relative to its top left corner).
1908 The icon will be aligned so that this point is at the
1909 marker's geographical location.
1910 shadow_image : string, file or array-like object, optional
1911 The data for the shadow image. If not specified,
1912 no shadow image will be created.
1913 shadow_size : tuple of 2 int, optional
1914 Size of the shadow image in pixels.
1915 shadow_anchor : tuple of 2 int, optional
1916 The coordinates of the "tip" of the shadow relative to its
1917 top left corner (the same as icon_anchor if not specified).
1918 popup_anchor : tuple of 2 int, optional
1919 The coordinates of the point from which popups will "open",
1920 relative to the icon anchor.
1921
1922 """
1923
1924 _template = Template(
1925 """
1926 {% macro script(this, kwargs) %}
1927 var {{ this.get_name() }} = L.icon({{ this.options|tojavascript }});
1928 {% endmacro %}
1929 """
1930 ) # noqa
1931
1932 def __init__(
1933 self,
1934 icon_image: Any,
1935 icon_size: Optional[Tuple[int, int]] = None,
1936 icon_anchor: Optional[Tuple[int, int]] = None,
1937 shadow_image: Any = None,
1938 shadow_size: Optional[Tuple[int, int]] = None,
1939 shadow_anchor: Optional[Tuple[int, int]] = None,
1940 popup_anchor: Optional[Tuple[int, int]] = None,
1941 ):
1942 super(Icon, self).__init__()
1943 self._name = "icon"
1944 self.options = remove_empty(
1945 icon_url=image_to_url(icon_image),
1946 icon_size=icon_size,

Callers

nothing calls this directly

Calls 1

TemplateClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…