我正在使用folium进行地图可视化。你知道如何将弹出窗口的背景颜色从白色更改为不同的颜色吗?
从这里How can I change the background color of a Leaflet popup?我知道这可以直接在Leaflet上找到,但我找到了与Folium有关的任何内容!
谢谢!
答案 0 :(得分:0)
选项1(手动):
使用编辑器软件打开.html
文件,并在<style>
标记中粘贴以下内容:.leaflet-popup-content-wrapper {background-color:black; color:white}
选项2(自动化):
创建地图并将其保存在path
中。
然后使用BeautifulSoup
。
from bs4 import BeautifulSoup
path = 'your/path/map.html'
soup = BeautifulSoup(open(path), "html.parser")
head = soup.head
head.append(soup.new_tag('style', type='text/css'))
head.style.append(' .leaflet-popup-content-wrapper {background-color:black; color:white}')
with open(path, "w") as file: file.write(str(soup))