ipyleaflet icon indicating copy to clipboard operation
ipyleaflet copied to clipboard

ipywidgets.Play doesn't work when the control is added after the map.

Open lopezvoliver opened this issue 1 year ago • 1 comments

As mentioned in the title, adding a control with a Play widget after the map is displayed somehow messes up the Play widget.

Here's the code to reproduce the normal behavior:

import ipyleaflet
import ipywidgets

m = ipyleaflet.Map(zoom=5, center=(40,-120))
play = ipywidgets.Play()
slider = ipywidgets.IntSlider(max=10)
box = ipywidgets.HBox(children=[play,slider])
control = ipyleaflet.WidgetControl(widget = box, position="topright")
ipywidgets.jslink((play,'value'),(slider,'value'))
m.add(control)
m

ipyleaflet-normal-play

Here's what happens if we move the m.add(control) line to another cell:

ipyleaflet-bug-play

Here's a slightly larger reproducible example that might be useful:

  1. Add the control with the slider to the map and display the map.
  2. In a new cell, display the Play widget. It works as expected.
  3. In a new cell, add the Play widget to the map --> the issue is reproduced.

ipyleaflet-bug-play-ext

lopezvoliver avatar Aug 20 '24 10:08 lopezvoliver