Plotly Mapbox: Markers and Hover Template

Hi all,
I have a dataframe that generates a map using the following code:

fig_map = px.scatter_mapbox(df_children,lat='Latitude',lon='Longitude',
                            mapbox_style='carto-positron',
                            width=1000,height=1000,color='column_02',size='population',
                            hover_name='address',
                            
                             hover_data={'address':True,'opening_hours':True
                            )

fig_map.update_traces(hovertemplate="Address: %{address} <br>Opening Hours: %{opening_hours}")
fig.update_traces(marker_symbol='cross',marker_size=12)

For implementation reasons I need to change the β€œcircle” that shows in the map to other symbol but what I get is an empty map in return.

Any idea how I can change the marker symbol?

Regarding the hover template, even if I have set the both columns as true, the resulting label does not render the rows of the column.
Screenshot 2022-04-01 at 15.14.11

Any idea how to change this behaviour?

Thank you for your help ,in advance!

Disclaimer: This is a project for an non-profit NGO with no commercial purposes.

Hi @jgomes_eu
Thank you for posting your question. I’m glad we were able to solve this together :slight_smile: Here’s the final answer.

If you have size and color properties in your scattermapbox, you can only use the circle marker. However, without size and color properties, you can use the other icons, as discussed in this topic. For example,

fig.update_traces(marker_symbol='airfield')

We need to ensure that you have a mapbox token for these icons to work.

Regarding the customized hover, you can add custom_data property to your figure and then update traces with customdata, like this:

fig = px.scatter_mapbox(df, [........], custom_data=['address', 'opening_hours'])
fig.update_traces(hovertemplate="Address is:  %{customdata[0]} <br> Hours of Operation: %{customdata[1]}")
fig.show()
1 Like

Thank you so much for your help on this, @adamschroeder!