Plotly 的layout.geo.fitbounds 属性未按预期工作
我正在使用 Plotly Express/Dash 解码折线以映射路线。我能够成功绘制路线并在 Dash 中显示地图,但无法让 layout.geo.fitbounds
属性按照文档中所述工作:
可以将
layout.geo.fitbounds
属性设置为locations
自动设置中心和经纬度范围 根据绘制的数据。
示例代码:
import plotly.express as px
import dash_core_components as dcc
fig = px.line_geo(lat=[0,15,20,35], lon=[5,10,25,30])
fig.update_geos(fitbounds="locations")
dcc.Graph(figure=fig)
app = dash.Dash()
app.layout = html.Div([
dcc.Graph(figure=fig)
])
app.run_server()
这会产生与我不向其传递 fitbounds
参数时相同的缩放级别:
我是否需要在 Dash 端进行一些格式化才能使自动缩放工作?
任何建议都非常感激。谢谢。
I'm decoding polylines to map routes using Plotly Express/Dash. I'm able to successfully plot routes and display the maps in Dash, but I'm unable to get the layout.geo.fitbounds
attribute to work as described in the documentation:
The
layout.geo.fitbounds
attribute can be set tolocations
to
automatically set the center and latitude and longitude range
according to the data being plotted.
Example code:
import plotly.express as px
import dash_core_components as dcc
fig = px.line_geo(lat=[0,15,20,35], lon=[5,10,25,30])
fig.update_geos(fitbounds="locations")
dcc.Graph(figure=fig)
app = dash.Dash()
app.layout = html.Div([
dcc.Graph(figure=fig)
])
app.run_server()
This results in the same zoom level as when I don't pass it a fitbounds
parameter:
Do I need to be doing some formatting on the Dash end to make auto-zoom work?
Any advice greatly appreciated. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论