Getting coordinates from hvplot map with user click/tap

I’m trying to follow this example to tap/click on a map and get the lat/lon coordinates in order to display a graph each time a different location is clicked. Couldn’t find an example that’s exactly like what I’m doing but seems like it should be working.

I copied the example in my jupyter notebook and it worked fine.

My code manages to display the map and also the graph using the initial x/y parameters set in the stream, but the function to create the graph is never called again despite clicking the map.

If anyone has any info I’d appreciate it, thanks.


map = dataset.hvplot.quadmesh('lon', 'lat', crs=ccrs.PlateCarree(), projection=ccrs.PlateCarree()
             ylim=('-100, 100'), rasterize=True, coastline=True)

stream = hv.streams.Tap(source=map, x=0, y=0)

def graph_func(x, y):
    #graphs a curve setting lon/lat to x and y

map + hv.DynamicMap(graph_func, streams=[stream])

Made an example program using an xarray tutorial dataset with the same issue. It displays the map and the initial curves graph but clicking the map doesn’t update the graph or call the graph_func().

import xarray as xr
import hvplot.pandas
import hvplot.xarray
import as ccrs
import holoviews as hv
import bokeh
import as ccrs
import panel as pn
import hvplot
import geoviews as gv

air_ds = xr.tutorial.open_dataset('air_temperature').load()

dataset = gv.Dataset(air_ds, vdims='air')


map = air_ds.hvplot.quadmesh('lon', 'lat', crs=ccrs.PlateCarree(), projection=ccrs.PlateCarree(), 
                        cmap='blues_r', project=True, geo=True,
                        rasterize=True, coastline=True, frame_width=600, clim=(0,1)).opts(toolbar='above')

def doSomething(x, y):
        curves =, longitude=stream.x).to(hv.Curve, ['time']).reindex().overlay()
        curves.opts(width=600, height=400, toolbar='above', xlabel=str(stream.x))
        return curves

stream = hv.streams.Tap(source=map, x=0, y=0)

map + hv.DynamicMap(doSomething, streams=[stream])
1 Like

Hi @DuckAficionado

Welcome to the community.

Please provide a minimum, reproducible example. This will make it much easier to understand the problem correctly and provide a relevant answer for the community. Thanks.