Skip to content

panel and ipyleaflet errors (Wrong widgets protocol, Comm is already created) #103

@misolietavec

Description

@misolietavec

Minimal example

import panel as pn
from ipyleaflet import Map, CircleMarker, MarkerCluster
from ipywidgets import Layout
pn.extension('ipywidgets')

mapcenter = [40.7, -74]
m =  Map(center=mapcenter, layout=Layout(width='400px', height='300px'))
points = []
for k in range(5):
    points.append(CircleMarker(location=[40.7 + 0.01, -74]))
cluster = MarkerCluster(markers=points)
m.add(cluster)

move = pn.widgets.FloatSlider(start=-74., end=-73.95, step=0.01)

@pn.depends(move)
def view_map(move):
    global cluster
    newcent = [40.7, move]
    m.center = newcent
    newmarks = []
    for k in range(5):
        newmarks.append(CircleMarker(location=[40.7 + 0.01, move]))
    cluster.markers = newmarks
    return m

only when executed via panel serve (testing this example in jupyter notebook is OK). After interaction with move slider, the map (initially shown properly) disappears and in development console there are multiple error messages of type:
Wrong widget protocol version: received protocol version '', but was expecting major version '2'
Uncaught (in promise) Error: Comm is already created
(thrown by ipywidgets_bokeh)

This happens with modules versions:
ipyleaflet: 0.18.1, 0.17.4
bokeh: 3.3.3
ipywidgets_bokeh: 1.5.0
panel: 1.3.6, 1.3.1
pyviz_comms: 2.3.2, 3.1.0
(tested in several conda or pip installed virtual environments)

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