首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的线下没有被嵌入一个支配的页面?

为什么我的线下没有被嵌入一个支配的页面?
EN

Stack Overflow用户
提问于 2022-11-17 01:44:07
回答 1查看 25关注 0票数 0

我正在用plotly.express创建一个地图,用独占创建一个html页面,我在支配部分上没有任何问题,我可以用映射部分创建一个单独的html页面。我的问题是,当我试图把地图变成一个html代码,并把它放在主导,它没有显示。地图在那里(我可以在html中看到它),但它没有显示。

所以我有一件事

代码语言:javascript
复制
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代码在那里,我就是看不到它。

我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-17 02:31:32

我检查了html后才找到答案。我把它留在这里以防别人需要它

我的错误是我应该写

代码语言:javascript
复制
the_map= pyo.plot(fig, include_plotlyjs=True, output_type='div')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74469212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档