I am using go.Scattermapbox in a python script for rendering location of objects. The underlying data changes on user interaction with another component. When the user selects another entity, the hover info for the plot updates to the correct labels and the hover data is diplayed in the correct position as it should, the map snaps to the right center point, but the actual markers themselves arenโt in the correct spot. They hang on the previously selected entity.
try:
fig.add_trace(
go.Scattermapbox(
name="Location 1",
lat=gen_df.latitude.unique().tolist(),
lon=gen_df.longitude.unique().tolist(),
mode="markers",
text=gen_df["name"].iloc[0],
hoverinfo="text",
)
)
except:
warnings.append("Location 1 has no coordinates")
try:
fig.add_trace(
go.Scattermapbox(
name="Location 2",
lat=gen_df.lat.unique().tolist(),
lon=gen_df.lon.unique().tolist(),
mode="markers",
text=gen_df["_id"].iloc[0],
hoverinfo="text",
)
)
except:
warnings.append("Location 2 has no coordinates")
fig.update_layout(
height=800,
autosize=True,
showlegend=True,
mapbox=dict(
accesstoken=MAPBOX_TOKEN,
bearing=0,
center=dict(
lat=gen_df.latitude.unique().tolist()[0],
lon=gen_df.longitude.unique().tolist()[0],
),
zoom=11,
pitch=0,
style="dark",
),
)
fig.show()