Element¶
-
class
folium.element.
Element
(template=None, template_name=None)¶ Basic Element object that does nothing. Other Elements may inherit from this one.
Parameters: TODO (docstring.) – -
add_child
(child, name=None, index=None)¶ Add a child.
-
add_children
(child, name=None, index=None)¶ Add a child.
-
add_to
(parent, name=None, index=None)¶ Add element to a parent.
-
get_bounds
()¶ Computes the bounds of the object and all it’s children in the form [[lat_min, lon_min], [lat_max, lon_max]].
-
get_name
()¶ TODO: docstring.
-
get_root
()¶ Returns the root of the elements tree.
-
render
(**kwargs)¶ Renders the HTML representation of the element.
-
save
(outfile, close_file=True, **kwargs)¶ Saves an Element into a file.
Parameters: - outfile (str or file object) – The file (or filename) where you want to output the html.
- close_file (bool, default True) – Whether the file has to be closed after write.
-
to_dict
(depth=-1, ordered=True, **kwargs)¶ TODO: docstring.
-
to_json
(depth=-1, **kwargs)¶ TODO: docstring.
-
MacroElement¶
-
class
folium.element.
MacroElement
¶ This is a parent class for Elements defined by a macro template. To compute your own element, all you have to do is:
To inherit from this class
Overwrite the ‘_name’ attribute
Overwrite the ‘_template’ attribute with something of the form:
{% macro header(this, kwargs) %} ... {% endmacro %} {% macro html(this, kwargs) %} ... {% endmacro %} {% macro script(this, kwargs) %} ... {% endmacro %}
-
render
(**kwargs)¶ Renders the HTML representation of the element.
Figure¶
-
class
folium.element.
Figure
(width='100%', height=None, ratio='60%', figsize=None)¶ Create a Figure object, to plot things into it.
Parameters: - width (str, default "100%") – The width of the Figure. It may be a percentage or pixel value (like “300px”).
- height (str, default None) – The height of the Figure. It may be a percentage or a pixel value (like “300px”).
- ratio (str, default "60%") – A percentage defining the aspect ratio of the Figure. It will be ignored if height is not None.
- figsize (tuple of two int, default None) – If you’re a matplotlib addict, you can overwrite width and height. Values will be converted into pixels in using 60 dpi. For example figsize=(10, 5) will result in width=”600px”, height=”300px”.
-
add_subplot
(x, y, n, margin=0.05)¶ TODO: docstring.
-
get_root
()¶ TODO: docstring.
-
render
(**kwargs)¶ Renders the HTML representation of the element.
-
to_dict
(depth=-1, **kwargs)¶ TODO: docstring.
Html¶
-
class
folium.element.
Html
(data, width='100%', height='100%')¶ Create an HTML div object for embedding data.
Parameters: - data (str) – The HTML data to be embedded.
- width (int or str, default '100%') – The width of the output div element. Ex: 120 , ‘120px’, ‘80%’
- height (int or str, default '100%') – The height of the output div element. Ex: 120 , ‘120px’, ‘80%’
Div¶
IFrame¶
-
class
folium.element.
IFrame
(html=None, width='100%', height=None, ratio='60%', figsize=None)¶ Create a Figure object, to plot things into it.
Parameters: - html (str, default None) – Eventual HTML code that you want to put in the frame.
- width (str, default "100%") – The width of the Figure. It may be a percentage or pixel value (like “300px”).
- height (str, default None) – The height of the Figure. It may be a percentage or a pixel value (like “300px”).
- ratio (str, default "60%") – A percentage defining the aspect ratio of the Figure. It will be ignored if height is not None.
- figsize (tuple of two int, default None) – If you’re a matplotlib addict, you can overwrite width and height. Values will be converted into pixels in using 60 dpi. For example figsize=(10, 5) will result in width=”600px”, height=”300px”.
-
render
(**kwargs)¶ Renders the HTML representation of the element.