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

Class Control

folium/features.py:2026–2081  ·  view source on GitHub ↗

Add a Leaflet Control object to the map Parameters ---------- control: str The javascript class name of the control to be rendered. position: str One of "bottomright", "bottomleft", "topright", "topleft" Examples -------- >>> import folium >>>

Source from the content-addressed store, hash-verified

2024
2025
2026class Control(JSCSSMixin, Class):
2027 """
2028 Add a Leaflet Control object to the map
2029
2030 Parameters
2031 ----------
2032 control: str
2033 The javascript class name of the control to be rendered.
2034 position: str
2035 One of "bottomright", "bottomleft", "topright", "topleft"
2036
2037 Examples
2038 --------
2039
2040 >>> import folium
2041 >>> from folium.features import Control, Marker
2042 >>> from folium.plugins import Geocoder
2043
2044 >>> m = folium.Map(
2045 ... location=[46.603354, 1.8883335], attr=None, zoom_control=False, zoom_start=5
2046 ... )
2047 >>> Control("Zoom", position="topleft").add_to(m)
2048 """
2049
2050 _template = Template(
2051 """
2052 {% macro script(this, kwargs) %}
2053 var {{ this.get_name() }} = new L.Control.{{this._name}}(
2054 {% for arg in this.args %}
2055 {{ arg | tojavascript }},
2056 {% endfor %}
2057 {{ this.options|tojavascript }}
2058 ).addTo({{ this._parent.get_name() }});
2059 {% endmacro %}
2060 """
2061 )
2062
2063 def __init__(
2064 self,
2065 control: Optional[str] = None,
2066 *args,
2067 position: Optional[TypePosition] = None,
2068 **kwargs,
2069 ):
2070 super().__init__()
2071 if control:
2072 self._name = control
2073
2074 if position is not None:
2075 position = position.lower() # type: ignore
2076 if position not in (args := get_args(TypePosition)):
2077 raise TypeError(f"position must be one of {args}")
2078 kwargs["position"] = position
2079
2080 self.args = args
2081 self.options = remove_empty(**kwargs)

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…