bokeh - 在散景应用程序中插入 folium map html 代码
问题描述
我将此作为在散景标签中包含 folium的后续问题发布,现在也作为一个新问题发布。
我正在尝试从我的 folium 地图中呈现原始 HTML 代码,但它不起作用.. 有什么想法吗?:)
div = Div(
text=map.get_root().render(),
width=x,
height=y
)
我宁愿能够将我的 folium 贴图直接渲染到散景 Div 对象中,而不是在旁边运行 Flask 应用程序。我已经研究了使用 iframe 的可能性,但我的代码似乎有问题here还有:
div.text = """<iframe srcdoc= """ + map.get_root().render() + """ height=""" + y + """ width=""" + x +"""></iframe>"""
我设法在侧边使用 Flask 应用程序来制作 folium 地图,然后将 url 用作 iframe 的 src,但后来我无法从我的散景工具更新该地图的内容。
随意对以上任何内容发表评论,干杯!:)
更新 - 测试脚本:
from bokeh.models.widgets import Div
from bokeh.layouts import row
from bokeh.plotting import curdoc
import folium
def run():
folium_map = folium.Map(location=(60., 20.))
div = Div(
text=folium_map._repr_html_(),
width=500,
height=500,
)
return row(div)
bokeh_layout = run()
doc = curdoc()
doc.add_root(bokeh_layout)
解决方案
有了map.get_root().render()
,您就拥有了所有的 HTML 页面。如果你只想要一个 iframe,你可以使用_repr_html_()
folium map 的方法:
div = Div(
text=map._repr_html_(),
width=x,
height=y
)
推荐阅读
- php - 带有 Laravel 的 JQuery 验证插件
- mysql - 使用两个查询制作水平视图
- r - RCurl Post 不适用于 kerberos 身份验证和 SSL
- sql - SQL |如何将单个日期列拆分为 SQL 表中的两列
- django - 在 crontab 中运行 Django 管理命令
- javascript - 如何仅使用 CSS3 将动态创建的元素平滑地添加到 DOM?
- c++ - C++:如何创建一个接受串联字符串作为参数的函数?
- c - C中优先级队列插入函数中的SIGSEV错误
- mongodb - Docker - 使用 MongoDB 创建第一个用户
- excel - Visual Studio Excel 插件 - VB.Net - 帮助避免不同数据范围的 vb.Null 错误