python - 如何增加 python folium 中的弹出窗口宽度?
问题描述
我正在遍历我的数据框,使用每列中的每个值来添加弹出窗口。但是弹出窗口的宽度太小,因此一个值显示在多行中。
这就是我的代码的样子:
c = folium.Map(
location=[12.323, 146.029326],
zoom_start=14
)
for row in df.itertuples():
name = getattr(row, "name")
age = getattr(row, "age")
folium.Marker(
location = location,
popup=folium.Popup(f"""name= {name} <br>
age = {age} <br>
"""),
icon=plugins.BeautifyIcon(
border_color = color,
border_width = 2,
text_color = 'black'
)
).add_to(c)
我想要每个列值有足够的空间。我怎样才能做到这一点?
解决方案
您可以使用对象的max_width
参数Popup
。您可以指定一个数字,该数字取决于名称行中的字符数,如下所示:
popup=folium.Popup(f"""name= {name} <br>
age = {age} <br>
""", max_width=len(f"name= {name}")*20),
推荐阅读
- http - Content-Transfer-Encoding 和 Content-Type 有什么区别
- r - 条件的长度 > 1 并且只使用第一个元素错误
- c++ - 在 C++ 中尝试从列表中删除对象时出错
- javascript - 如何使用 javascript 和 html 锁定页面/内容
- python - 在python中运行ghostscript不起作用
- javascript - 打字稿(错误TS2322):类型'{类型:ErrorPageType; }' 不可分配给类型 'ErrorPageType.SIGNUP'
- set - 简单基数证明
- android - 如何在 RecyclerView kotlin 的两个不同视图上实现两个 OnClickListener?
- google-api - Google 云端硬盘功能差异
- google-sheets - JOIN header row values across a row based on non-blank values in cells