gpt4 book ai didi

python - 叶时间 slider 不会删除 map 中先前添加的标记

转载 作者:行者123 更新时间:2023-12-04 04:14:58 25 4
gpt4 key购买 nike

我正在尝试使用时间 slider 绘制标记。我创建了带时间戳的geojson,如下所示:

def create_geojson_features(df):

features = []
for lat,lan,intensity,time in zip(df['latitude'],df['longitude'],df['intensity'],df['timestamp']):
time = str(time)
feature = {
'type': 'Feature',
'geometry': {
'type':'Point',
'coordinates':[lan,lat]
},
'properties': {
'time': time,
'style': {'Color' : color(intensity)},
'icon': 'Marker',
'color':color(intensity),
'iconstyle':{
'Color': color(intensity),
'fillOpacity': 0.8,
'stroke': 'true',
'radius': 7
}
}
}
features.append(feature)
return features
features = create_geojson_features(df)

这是我绘制标记的代码
from folium.plugins import TimestampedGeoJson
m = folium.Map([latmean,lonmean], zoom_start=11)

TimestampedGeoJson(
{'type': 'FeatureCollection',
'features': features}
, period='PT1H'
, add_last_point=False
, auto_play=False
, loop=False
, max_speed=1
, loop_button=True
, date_options='YYYY/MM/DD HH:mm:ss'
, time_slider_drag_update=True
).add_to(m)

我已将周期指定为 PT1H,当我滚动 slider 时,新点会不断添加。如何删除旧点并仅显示新点?请帮忙。

最佳答案

有一个参数就是:duration = 'P1D'
以您的示例为例,并且仅显示每个时间戳:

TimestampedGeoJson(
{'type': 'FeatureCollection',
'features': features}
, period='PT1H'
, duration='PT1H'
, add_last_point=False
, auto_play=False
, loop=False
, max_speed=1
, loop_button=True
, date_options='YYYY/MM/DD HH:mm:ss'
, time_slider_drag_update=True
).add_to(m)

关于python - 叶时间 slider 不会删除 map 中先前添加的标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60909832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com