55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
|
from branca.element import CssLink, Figure, JavascriptLink, MacroElement
|
||
|
|
||
|
from jinja2 import Template
|
||
|
|
||
|
|
||
|
class FoliumCSS(MacroElement):
|
||
|
_template = Template("""
|
||
|
{% macro header(this, kwargs) %}
|
||
|
<style>
|
||
|
{{ this.style }}
|
||
|
</style>
|
||
|
{% endmacro %}
|
||
|
""")
|
||
|
|
||
|
def __init__(self, style=""""""):
|
||
|
super(FoliumCSS, self).__init__()
|
||
|
self.style = style
|
||
|
|
||
|
|
||
|
class FoliumJavascript(MacroElement):
|
||
|
_template = Template("""
|
||
|
{% macro script(this, kwargs) %}
|
||
|
{{ this.code }}
|
||
|
{% endmacro %}
|
||
|
""")
|
||
|
|
||
|
def __init__(self, code="""alert('no code here');"""):
|
||
|
super(FoliumJavascript, self).__init__()
|
||
|
self.code = code
|
||
|
|
||
|
def add_to(self, m):
|
||
|
self.map_name = m.get_name()
|
||
|
super(FoliumJavascript, self).add_to(m)
|
||
|
|
||
|
|
||
|
class FoliumCSSAndJavaScript(MacroElement):
|
||
|
_template = Template("""
|
||
|
{% macro header(this, kwargs) %}
|
||
|
<style>
|
||
|
{{ this.style }}
|
||
|
</style>
|
||
|
<script langauge="JavaScript">
|
||
|
{{ this.code }}
|
||
|
</script>
|
||
|
{% endmacro %}
|
||
|
""")
|
||
|
|
||
|
def __init__(self, style="""""", code=""""""):
|
||
|
super(FoliumCSSAndJavaScript, self).__init__()
|
||
|
self.style=style
|
||
|
self.code=code
|
||
|
|
||
|
def add_to(self, m):
|
||
|
self.map_name = m.get_name()
|
||
|
super(FoliumCSSAndJavaScript, self).add_to(m)
|