I am attempting to run the basic google maps example (https://panel.holoviz.org/user_guide/Param.html) 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
pn.extension()
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
self.country = countries[0]
@param.depends('country')
def view(self):
iframe = """
<iframe width="800" height="400" src="https://maps.google.com/maps?q={country}&z=6&output=embed"
frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
""".format(country=self.country)
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.
Thanks!