Skip to content

Map distance app error when switching maps #27

@davidwilby

Description

@davidwilby

Thanks for the awesome templates!

I'm finding that the map-distance app is erroring when switching maps on a local deployment (the gallery app is fine)

Python version 3.12 and 3.11 tried.

Environment tested python 3.11.11 ❯ pip freeze anyio==4.8.0 appdirs==1.4.4 asgiref==3.8.1 asttokens==3.0.0 branca==0.8.1 certifi==2024.12.14 charset-normalizer==3.4.1 click==8.1.8 comm==0.2.2 decorator==5.1.1 executing==2.1.0 faicons==0.2.2 geographiclib==2.0 geopy==2.4.1 h11==0.14.0 htmltools==0.6.0 idna==3.10 ipyleaflet==0.19.2 ipython==8.31.0 ipywidgets==8.1.5 jedi==0.19.2 Jinja2==3.1.5 jupyter-leaflet==0.19.2 jupyter_core==5.7.2 jupyterlab_widgets==3.0.13 linkify-it-py==2.0.3 markdown-it-py==3.0.0 MarkupSafe==3.0.2 matplotlib-inline==0.1.7 mdit-py-plugins==0.4.2 mdurl==0.1.2 narwhals==1.21.1 orjson==3.10.14 packaging==24.2 parso==0.8.4 pexpect==4.9.0 platformdirs==4.3.6 prompt_toolkit==3.0.48 ptyprocess==0.7.0 pure_eval==0.2.3 Pygments==2.19.1 python-dateutil==2.9.0.post0 python-multipart==0.0.20 questionary==2.1.0 requests==2.32.3 shiny==1.2.1 shinywidgets==0.4.2 six==1.17.0 sniffio==1.3.1 stack-data==0.6.3 starlette==0.45.2 traitlets==5.14.3 traittypes==0.2.1 typing_extensions==4.12.2 uc-micro-py==1.0.3 urllib3==2.3.0 uvicorn==0.34.0 watchfiles==1.0.3 wcwidth==0.2.13 websockets==14.1 widgetsnbextension==4.0.13 xyzservices==2024.9.0

The following error is raised when choosing a different map from the dropdown, e.g. starting with WorldImagery and selecting Mapnik:

Traceback (most recent call last):
  File ".../lib/python3.11/site-packages/shiny/reactive/_reactives.py", line 584, in _run
    await self._fn()
  File ".../lib/python3.11/site-packages/shiny/_utils.py", line 279, in fn_async
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "./map-distance/app.py", line 165, in _
    update_basemap(map.widget, input.basemap())
  File "./map-distance/app.py", line 185, in update_basemap
    map.remove(layer)
  File ".../lib/python3.11/site-packages/ipyleaflet/leaflet.py", line 3168, in remove
    if item.model_id not in self._layer_ids:
       ^^^^^^^^^^^^^
  File ".../lib/python3.11/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.11/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'

The app then freezes:

Image

Also note that when a different map is selected and the page is refreshed, the new map loads correctly, e.g. Mapnik in this example:

Image

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