我正在用plotly.express创建一个地图,用独占创建一个html页面,我在支配部分上没有任何问题,我可以用映射部分创建一个单独的html页面。我的问题是,当我试图把地图变成一个html代码,并把它放在主导,它没有显示。地图在那里(我可以在html中看到它),但它没有显示。
所以我有一件事
import dominate
from dominate.tags import *
from dominate.util import raw
import plotly.express as px
import plotly.offline as pyo
import pandas as pd
#Here get some dataframe with Latitude and Longitude and ImageNo data
can_whole_df=get_some_df()
fig = px.scatter_mapbox(can_whole_df, lat="Latitude", lon="Longitude",
zoom=10,
text = 'ImageNo'
)
fig.update_layout(mapbox_style="open-street-map", margin={"r":0,"t":0,"l":0,"b":0})
fig.write_html("debugmap.html") #<---THIS WORKS. (I can see the map separatedly)
#Here I take the map and put it in some code to embed it in dominate
the_map= pyo.plot(fig, include_plotlyjs=False, output_type='div')
doc=dominate.document(title="some map")
with doc.head:
link(rel='stylesheet', href='style.css')
with doc:
h1("The Map in all its glory!")
# with div(id='map'):
# p('Here goes a map')
# raw(the_map)
raw(the_map)
print(doc)因此,我可以在它自己的文件(debugmap.html)中看到映射,但是当我将主导输出保存到html页面时,我无法看到它。
考虑到html代码在那里,我就是看不到它。
我做错了什么?
发布于 2022-11-17 02:31:32
我检查了html后才找到答案。我把它留在这里以防别人需要它
我的错误是我应该写
the_map= pyo.plot(fig, include_plotlyjs=True, output_type='div')https://stackoverflow.com/questions/74469212
复制相似问题