Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

Display polygons with hoverdata in mapbox

I have a dash app with a mapbox plot in it. My app reads in a shapefile geometry column and then plots the polygons (corresponding to regions in Australia) onto the mapbox plot as a layer. It can also read in a latitude and longitude column and plot those point on the same map (as a trace).

My problem is that I want the polygons to be hoverable, so that when I hover over them (like I would with the lat/long data in the trace) I get some extra information. I found a way to do this by calculating the lat/long centroid of each polygon and plotting those as a separate data trace with opacity 0, but this is a bit hacky and results in some loss of functionality further down the road. Is there any other way to get some polygons with hover data? It would be great if I could display them through a trace rather than an added layer.

I can give more information if necessary, but I am trying to keep the question simple.

If I understand your question correctly, you just need to customize the hover info of the trace? That can easily be done,

Hey there,

were you able to figure this out? I think I’m getting the same issue – I can’t get hoverinfo to display above the fill area of a polygon. Hoverinfo popups only display along the coordinates on the boundary of the polygon.

Can you describe more about what are you using? Are you using mapbox_choropleth or the geojson property in layout.mapbox? A simple example and a screenshot would be helpful.

Sure, see Hoverinfo over fill area of polygon