单击按钮

时间:2019-08-03 13:56:39

标签: python plotly plotly-dash

我正在尝试在单击按钮时添加一个scattermapbox行,并使其卡住。有人知道执行刷新div的命令吗?我的布局在下面,我可以使用以下代码在加载时绘制地图:

import plotly.graph_objs as go    
data = [go.Scattermapbox(
    lat=[52.038459, 52.038459, 52.060934, 52.038459, 52.015984, 51.993509, 51.971034, 51.948559, 51.948559, 51.948559, 51.948559, 51.926084],
            lon=[-1.250252269, -1.2867081345, -1.323164, -1.2867081345, -1.250252269, -1.2137964035, -1.177340538, -1.1408846725, -1.104428807, -1.0679729414999999, -1.031517076, -0.9950612105],

    mode='markers',
            hoverinfo='none',
            marker=go.scattermapbox.Marker(
                size=5,
                color='black',
            ),
            # textfont=dict(color='red')
        )]

    layout = go.Layout(
        autosize=True,
        margin=dict(l=0,
                    r=0,
                    t=0,
                    b=0),
        hovermode='closest',
        clickmode='event+select',
        showlegend=False,
        mapbox=dict(
            accesstoken=mapbox_access_token,
            bearing=0,
            center=dict(
                lat=51.672,
                lon=-0.953
            ),
            style='light',
            pitch=0,
            zoom=9
        ),
    )    
    app.layout = html.Div(id='pageContainer',
                              children=[
                                  dcc.Graph(
                                      id='mapContainer',
                                      figure={
                                          'data': data,
                                          'layout': layout
                                      }
                                  ),
        ])

但是,当我尝试将相同的代码移到按钮回调中时,它不会运行。有任何想法吗?如何强制其刷新并显示在mapcontainer图形中?

0 个答案:

没有答案