Dear fellow users, hi I am new here.
I have a database containing a series of ground stations. Two columns are in this database are:
df['From] # first date for that ground station
df['To'] # last date for that station
I have created a slider (range selector) to pick my start and end date, and would like to have the corresponding stations appearing (or disappearing) on the map, that should update in real time.
However, it does not update. I am also printing a map title, where number of “active” stations (for that time range) change according to user-selected time window.
When moving the slider, I can observe :
- no markers appearing or disappearing(they remain the same number);
- The number of active stations changing in the title, depending on the user-selected time-window;
- the map flicking, as I suppose it is centering to the new (filtered) dataset
- the map disappearing when the number of stations equals zero.
- if, in my python code, I add fig.show() a new tab is opened and the map with the filtered stations is shown. However, my goal is having an “inplace” and “instantaneous” update of the markers (stations).
- if, instead of mapbox, I use a normal scatter plot, the mechanism works and the plot (not map) is being updated in real time. Could it depend on the token?
I am using mapbox and I requested and obtained my access token.
Some images:
What I am doing wrong?
##The slider:
app.layout = html.Div([
dcc.Graph(id=‘graph-with-slider’),
dcc.RangeSlider(
min=slider_values[0],
max=slider_values[-1],
step=1,
pushable=1,
marks={str(year): str(year) for year in slider_values},
value=[slider_values[0], slider_values[-1]],
tooltip={“placement”: “bottom”, “always_visible”: True},
id=‘year-slider’
)
])
#The callback:
@app.callback(
Output(‘graph-with-slider’, ‘figure’),
Input(‘year-slider’, ‘value’))
The Map
df, slider_values = process_data(data_folder, fileName)
#Compute timestamps for masking data
t0 = datetime.datetime(selected_year[0], 1, 1)
te = datetime.datetime(selected_year[1]+1, 1, 1)
####
#Build a mask for dataframe:
mask = (df['From'] >= t0) & (df['To'] <= te)
filtered_df = df[mask]
####
token = # the token....
fig = px.scatter_mapbox(filtered_df, lat="lat", lon="lon",
hover_name="Station Name",
zoom=8,
#center=dict(lat=34.9, lon=33.5274), ## to prevent flickering
height=400)
Thanks for any help you might be willing to give me.
Bye,
Marco