Param view() method not updating in notebook

I am attempting to run the basic google maps example ( in the documentation. My main problem is that the view() method doesn’t seem to be called when running it in a notebook:

import panel as pn
import param

class GoogleMapViewer(param.Parameterized):
    continent = param.ObjectSelector(default='Asia', objects=['Africa', 'Asia', 'Europe'])
    country = param.ObjectSelector(default='China', objects=['China', 'Thailand', 'Japan'])
    _countries = {'Africa': ['Ghana', 'Togo', 'South Africa', 'Tanzania'],
                  'Asia'  : ['China', 'Thailand', 'Japan'],
                  'Europe': ['Austria', 'Bulgaria', 'Greece', 'Portugal', 'Switzerland']}
    @param.depends('continent', watch=True)
    def _update_countries(self):
        countries = self._countries[self.continent]
        self.param['country'].objects = countries = countries[0]

    def view(self):
        iframe = """
        <iframe width="800" height="400" src="{country}&z=6&output=embed"
        frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
        return pn.pane.HTML(iframe, height=400)
viewer = GoogleMapViewer(name='Google Map Viewer')
pn.Row(viewer.param, viewer.view)

The problem is that when I select a different country, the map isn’t updating at all:

My library versions:

bokeh 2.1.0
param 1.9.3
panel 0.9.5

When I run the example on the documentation website, the map does update when changing countries, but only if the default continent (Asia) is selected.


Your example works but when you use method show (i.e. when the app opens in new tab). The question is why it is happening? I hope that someone will explain it here, as I observed the same behavior in my code.

Anyways, try this:

pn.Row(viewer.param, viewer.view).show()

You should try Bokeh<2.1.0, since there is a javascript error:

1 Like