我在folium中创建了一个带有图层的地图对象“mymap”,并希望在完成后完全清除它。
mymap =()和del(mymap)似乎不起作用。有谁知道这是否可行?
如果这有帮助,我将如何从熊猫创建地图:
import pandas as pd
import folium
from collections import defaultdict
ddfg = defaultdict()
for layer in dftemp['layers'].unique():
ddfg[layer] = folium.FeatureGroup(name=layer)
mymap = folium.Map(location=[lat_mean, lon_mean], zoom_start=14, tiles='Stamen Toner')
for lat,lon,popup,color in zip(dftemp['lat'],dftemp['lon'],dftemp['popup'],
dftemp['color']):
ddfg[layer].add_child(folium.CircleMarker([lat,lon],radius=10,popup=popup,color=color))
for fg in ddfg.values():
mymap.add_child(fg)
mymap.add_child(folium.LayerControl())