Skip to content

Commit 7c15ac2

Browse files
committed
Removed CustomControl from this PR
1 parent fb4047f commit 7c15ac2

File tree

1 file changed

+0
-70
lines changed

1 file changed

+0
-70
lines changed

folium/features.py

-70
Original file line numberDiff line numberDiff line change
@@ -2047,73 +2047,3 @@ def __init__(
20472047
kwargs.pop(key)
20482048

20492049
self.options = parse_options(**kwargs)
2050-
2051-
2052-
class CustomControl(Control):
2053-
"""Display static html and switch together with parent layer.
2054-
2055-
Parameters
2056-
----------
2057-
html: str
2058-
The html to be rendered
2059-
style: str
2060-
The css style to be applied to this element
2061-
position: str
2062-
One of "bottomright", "bottomleft", "topright", "topleft"
2063-
2064-
Examples
2065-
--------
2066-
>>> m = folium.Map(
2067-
... location=[46.603354, 1.8883335], zoom_control=False, zoom_start=5
2068-
... )
2069-
>>> CustomControl("This is my custom control", position="topleft").add_to(m)
2070-
"""
2071-
2072-
_template = Template(
2073-
"""
2074-
{% macro header(this,kwargs) %}
2075-
{%- if this.style %}
2076-
<style>
2077-
.class_{{this.get_name()}} {{ "{" }} {{this.style}} {{ "}" }}
2078-
</style>
2079-
{%- endif %}
2080-
{% endmacro %}
2081-
2082-
{% macro script(this, kwargs) %}
2083-
2084-
var {{ this.get_name() }} = L.control({
2085-
position: "{{ this.position }}",
2086-
});
2087-
{{ this.get_name() }}.onAdd = function(map) {
2088-
let div = L.DomUtil.create('div', 'class_{{this.get_name()}}');
2089-
div.innerHTML = `{{ this.html }}`;
2090-
return div;
2091-
}
2092-
{{ this.get_name() }}.addTo({{ this.parent_map.get_name() }});
2093-
2094-
{%- if this.switch %}
2095-
{{ this._parent.get_name() }}.on('add', function(e) {
2096-
{{ this.get_name() }}.addTo({{ this.parent_map.get_name() }});
2097-
});
2098-
{{ this._parent.get_name() }}.on('remove', function(e) {
2099-
e.target._map.removeControl({{ this.get_name() }});
2100-
});
2101-
{%- endif %}
2102-
2103-
{% endmacro %}
2104-
"""
2105-
)
2106-
2107-
def __init__(self, html, style=None, position="bottomleft"):
2108-
super().__init__()
2109-
self._name = "custom_control"
2110-
self.style = style
2111-
self.html = escape_backticks(html)
2112-
self.position = position
2113-
self.parent_map = None
2114-
self.switch = None
2115-
2116-
def render(self, **kwargs):
2117-
self.parent_map = get_obj_in_upper_tree(self, Map)
2118-
self.switch = isinstance(self._parent, Layer) and self._parent.control
2119-
super().render(**kwargs)

0 commit comments

Comments
 (0)