Black Lives Matter. Please consider donating to Black Girls Code today.

Show labels on hover in a multi-layer Mapbox

I’m creating a Dash app in which I’m drawing points and lines on a map as suggested here: How to plot lines between locations on a map at a city level=

However, I need different points and lines to be of different sizes (or widths) and colors, so I have had to create separate layers for each of them and pass them in the layout to an empty go.Scattermapbox(). Now, I want to show labels when the user hovers upon a point on the map. Is there any way to do this?

I’m ideally looking for something of this sort: https://www.mapbox.com/mapbox-gl-js/example/popup-on-hover/, but I’m not sure how to use the properties within the GeoJSON source to modify something.

Thanks

@muser The answer is YES, you can plot points of different sizes and colors, and display multiline-text on hover:
https://plot.ly/~empet/14398

The points are not defined in the list of layers though, but in a scattermapbox type trace:

trace=dict(type='scattermapbox',
            lon=lon,
            lat=lat,
            mode='markers',
            text=regions,
            marker=dict(size=[5]*11+[8]*11, color=['red']*11+['green']*11),
            hoverinfo='text'
             )

For more details inspect the corresponding code of the above plot, here:https://plot.ly/~empet/14398#code,
choosing Python from the dropdown menu.

If you have lines of different widths and colors, then you should define a layer for each one, in the list of layers.

Thanks! Defining the points in a trace instead of a layer did the trick.