Я пытаюсь удалить маркеры, добавленные на каждой итерации внутри create_geojson_feature при запуске ползунка, однако карта продолжает добавлять маркеры и не удаляет старые
from folium.plugins import TimestampedGeoJson
def create_geojson_features(df):
print('> Creating GeoJSON features...')
features = []
for _, row in df.iterrows():
feature = {
'type': 'Feature',
'geometry': {
'type':'Point',
'coordinates':[row['longitude_c'],row['latitude_c']]
},
'properties': {
'time': row['datetime'].date().__str__(),
# 'style': {'color' : row['color']},
'style': {'color' : 'red'},
'icon': 'circle',
'iconstyle':{
# 'fillColor': row['color'],
'fillOpacity': 0.8,
'stroke': 'true',
'radius': 7
}
}
}
features.append(feature)
return features
features = create_geojson_features(df_storm)
Метод make_map использует функции json из create_ge json метод
def make_map(features):
print('> Making map...')
coords_belgium=[50.5039, 4.4699]
pollution_map = folium.Map(location=coords_belgium, control_scale=True, zoom_start=8)
TimestampedGeoJson(
{'type': 'FeatureCollection',
'features': features}
, period='P1M'
, add_last_point=False
, auto_play=False
, loop=False
, max_speed=1
, loop_button=True
, date_options='YYYY/MM'
, time_slider_drag_update=True
).add_to(m)
print('> Done.')
return