0

I've installed ipyleaflet in jupyter lab using based on the following guide: https://ipyleaflet.readthedocs.io/en/latest/installation/index.html#jupyterlab-extension

The following code executes, the map is shown correctly but the layers (in this case one Marker) are not showing up.

from ipyleaflet import Map, Marker
center = [21.501558, 39.184964]
m = Map(center=center, zoom=15)
marker = Marker(location=center, draggable=True)
m.add_layer(marker)
display(m)

The browser console shows the following warnings:

Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early
_loadFromKernel
Could not create a view for model id ...

Followed by an error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '_layerAdd')
    at e.addLayer (leaflet-src.js:6889:16)
    at 138.69ef2a39232f5de9d78a.js?v=69ef2a39232f5de9d78a:1:39625
    at async Promise.all (index 1)

What could be the reason for layers not showing up on the correctly rendered map?

Ilya Zinkovich
  • 4,082
  • 4
  • 25
  • 43
  • Aside: you don't say specifically how you installed. There's four different options listed at where you link. – Wayne Jan 09 '23 at 22:15
  • @Wayne I installed it as a Jupyter lab extension and as a python module using pip – Ilya Zinkovich Jan 10 '23 at 22:28
  • ipywidgets works otherwise in the notebooks where ipyleaflet isn't working as you expect? I ask because ipywidgets can be tricky to get the installation 100%. For example, most things I can use `conda install` or `pip install` later in a running session via MyBinder and it will work. ipywidgets I have to install during building of the image to run the session or it doesn't quite work. It's not a 1:1 equivalent but just a cautionary tale that ipywidgets can be tricky. I would think it is that or not quite corresponding versions possibly. – Wayne Jan 11 '23 at 03:52
  • If you'd like a place where things work correctly for comparison, you can can [here](https://github.com/jupyter-widgets/ipyleaflet#ipyleaflet) and press the `launch binder` badge. Your first code block works pasted in a cell in JupyterLab there. There's also a couple of demo notebooks in there about 'MarkerCluster' that come up if you put 'marker' in the search. And I found with grep search that marker is demonstrated in 'Primitives.ipynb`. Add a cell with `m` in at the conclusion of that section to play with the transparency slider instead of scrolling back up. – Wayne Jan 11 '23 at 19:57

0 Answers0