import sys
sys.path.insert(0,'folium')
import folium
import folium.plugins
from folium.features import *
To create this, you need to enhance the DivIcon
class that's not really finished on the master.
class DivIcon(MacroElement):
def __init__(self, html='', size=(30,30), anchor=(0,0), style=''):
"""TODO : docstring here"""
super(DivIcon, self).__init__()
self._name = 'DivIcon'
self.size = size
self.anchor = anchor
self.html = html
self.style = style
self._template = Template(u"""
{% macro header(this, kwargs) %}
<style>
.{{this.get_name()}} {
{{this.style}}
}
</style>
{% endmacro %}
{% macro script(this, kwargs) %}
var {{this.get_name()}} = L.divIcon({
className: '{{this.get_name()}}',
iconSize: [{{ this.size[0] }},{{ this.size[1] }}],
iconAnchor: [{{ this.anchor[0] }},{{ this.anchor[1] }}],
html : "{{this.html}}",
});
{{this._parent.get_name()}}.setIcon({{this.get_name()}});
{% endmacro %}
""")
m = folium.Map([34.0302, -118.2352], zoom_start=13)
#folium.features.LatLngPopup().add_to(m)
folium.map.Marker(
[34.0302, -118.2352]).add_to(m)
folium.map.Marker(
[34.0302, -118.2352],
icon=DivIcon(
size=(150,36),
anchor=(150,0),
html='Test',
style="""
font-size:36px;
background-color: transparent;
border-color: transparent;
text-align: right;
"""
)
).add_to(m)
m
That's it.