from branca.element import MacroElement from folium.template import Template class ScrollZoomToggler(MacroElement): """Creates a button for enabling/disabling scroll on the Map.""" _template = Template( """ {% macro header(this,kwargs) %} {% endmacro %} {% macro html(this,kwargs) %} scroll {% endmacro %} {% macro script(this,kwargs) %} {{ this._parent.get_name() }}.scrollEnabled = true; {{ this._parent.get_name() }}.toggleScroll = function() { if (this.scrollEnabled) { this.scrollEnabled = false; this.scrollWheelZoom.disable(); } else { this.scrollEnabled = true; this.scrollWheelZoom.enable(); } }; {{ this._parent.get_name() }}.toggleScroll(); {% endmacro %} """ ) def __init__(self): super().__init__() self._name = "ScrollZoomToggler"