Skip to content

Commit 72c419b

Browse files
committed
Merge pull request #243 from BibMartin/icon_prefix
More docstrings and options in Icon
2 parents a6664e7 + d5ce0b9 commit 72c419b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

folium/map.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,44 @@ def render(self, **kwargs):
254254
super(LayerControl, self).render()
255255

256256
class Icon(MacroElement):
257-
def __init__(self, color='blue', icon='info-sign', angle=0):
258-
"""TODO : docstring here"""
257+
def __init__(self, color='blue', icon_color='white', icon='info-sign', angle=0, prefix='glyphicon'):
258+
"""Creates an Icon object, that will be rendered using Leaflet.awesome-markers.
259+
260+
Parameters
261+
----------
262+
color : str, default 'blue'
263+
The color of the marker. You can use:
264+
['red', 'blue', 'green', 'purple', 'orange', 'darkred', 'lightred', 'beige',
265+
'darkblue', 'darkgreen', 'cadetblue', 'darkpurple', 'white', 'pink', 'lightblue',
266+
'lightgreen', 'gray', 'black', 'lightgray']
267+
icon_color : str, default 'white'
268+
The color of the drawing on the marker. You can use colors above, or an html color code.
269+
icon : str, default 'info-sign'
270+
The name of the marker sign. See Font-Awesome website to choose yours.
271+
Warning : depending on the icon you choose, you may need to adapt the `prefix` as well.
272+
angle : int, default 0
273+
The icon will be rotated by this amount of degrees.
274+
prefix : str, default 'glyphicon'
275+
The prefix states the source of the icon. 'fa' for font-awesome or 'glyphicon' for bootstrap 3.
276+
277+
For more details, see https://github.com/lvoogdt/Leaflet.awesome-markers
278+
"""
259279
super(Icon, self).__init__()
260280
self._name = 'Icon'
261281
self.color = color
262282
self.icon = icon
283+
self.icon_color = icon_color
263284
self.angle = angle
285+
self.prefix = prefix
264286

265287
self._template = Template(u"""
266288
{% macro script(this, kwargs) %}
267289
268290
var {{this.get_name()}} = L.AwesomeMarkers.icon({
269291
icon: '{{this.icon}}',
292+
iconColor: '{{this.icon_color}}',
270293
markerColor: '{{this.color}}',
271-
prefix: 'glyphicon',
294+
prefix: '{{this.prefix}}',
272295
extraClasses: 'fa-rotate-{{this.angle}}'
273296
});
274297
{{this._parent.get_name()}}.setIcon({{this.get_name()}});

0 commit comments

Comments
 (0)