Skip to content

Commit 3444306

Browse files
committed
Add draggable option to Marker
1 parent 49d724d commit 3444306

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

folium/map.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ class Marker(MacroElement):
221221
Display a text when hovering over the object.
222222
icon: Icon plugin
223223
the Icon plugin to use to render the marker.
224+
draggable: bool, default False
225+
Set to True to be able to drag the marker around the map.
224226
225227
Returns
226228
-------
@@ -239,17 +241,23 @@ class Marker(MacroElement):
239241
var {{this.get_name()}} = L.marker(
240242
[{{this.location[0]}}, {{this.location[1]}}],
241243
{
242-
icon: new L.Icon.Default()
244+
icon: new L.Icon.Default(),
245+
{%- if this.draggable %}
246+
draggable: true,
247+
autoPan: true,
248+
{%- endif %}
243249
}
244250
).addTo({{this._parent.get_name()}});
245251
{% endmacro %}
246252
""")
247253

248-
def __init__(self, location, popup=None, tooltip=None, icon=None):
254+
def __init__(self, location, popup=None, tooltip=None, icon=None,
255+
draggable=False):
249256
super(Marker, self).__init__()
250257
self._name = 'Marker'
251258
self.tooltip = tooltip
252259
self.location = _validate_coordinates(location)
260+
self.draggable = draggable
253261
if icon is not None:
254262
self.add_child(icon)
255263
if isinstance(popup, text_type) or isinstance(popup, binary_type):

0 commit comments

Comments
 (0)