Skip to content

Interaction in ipyleaflet maps stopped working in v0.4.0+ #174

@thohan88

Description

@thohan88

First of all, thanks for all the work on bringing ipywidgets to shiny, it is fantastic and much appreciated.

Description:
Since updating shinywidgets to v0.4.0, apps using ipyleaflet for interactive map updates (e.g., adding, updating, and removing markers) have stopped working. The app exits on update and the error message below is shown in the terminal. This issue seems to be introduced in commit 72d16f5. Installing from all previous commits (<=v0.3.4.9000) works perfectly.

Reproducible example:

Local environment:

  • python: 3.11
  • shiny: 1.2.1
  • shinywidgets: 0.4.0+
  • ipyleaflet: 0.19.1
  • ipywidgets: 8.1.5

Error message (shinylive):

Traceback (most recent call last):
  File "/lib/python3.12/site-packages/shiny/reactive/_reactives.py", line 584, in _run
    await self._fn()
  File "/lib/python3.12/site-packages/shiny/_utils.py", line 279, in fn_async
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/pyodide/app_kh331apovkrx44kaospm/app.py", line 36, in update_markers
    m.add(markers[id])
  File "/lib/python3.12/site-packages/ipyleaflet/leaflet.py", line 3150, in add
    self.layers = tuple([layer for layer in self.layers] + [item])
    ^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 716, in __set__
    self.set(obj, value)
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 690, in set
    new_value = self._validate(obj, value)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 724, in _validate
    value = self._cross_validate(obj, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 730, in _cross_validate
    value = obj._trait_validators[self.name](obj, proposal)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 1241, in __call__
    return self.func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/ipyleaflet/leaflet.py", line 2971, in _validate_layers
    self._layer_ids = [layer.model_id for layer in proposal.value]
                       ^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/ipywidgets/widgets/widget.py", line 552, in model_id
    return self.comm.comm_id
           ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'comm_id'
/lib/python3.12/site-packages/shiny/reactive/_reactives.py:566: ReactiveWarning: Error in Effect: 'NoneType' object has no attribute 'comm_id'
  await self._run()
Unhandled error: 'NoneType' object has no attribute 'comm_id'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions