I have a button in app layout and a callback function tied to the mapbox graph that is updated based on
html.Div([
dbc.Button("Run", id="run-button", size="lg", className="mr-1"),
], style={"width":"50%", "margin-top": "-17.5%"}),
In the callback function, I calculate the value based on inputs that I’d like to use in the pop-up.
# Update map graph
@app.callback(Output("map-graph1", "figure"),
[
Input("input1", "val1"),
Input("input2", "val2"),
Input('run-button",'n_clicks")
]
)
def update_graph(val1, val2, nclicks):
**calc_val = val1 * val2**
data = []
# Color by category group by
for i, row in df_lease.iterrows():
lat = row['Lat']
lng = row['Long']
rent = row['Rent(SF/Yr)']
submarket = row['SubMarket']
data.append({
"type": "scattermapbox",
"lat": [lat],
"lon": [lng],
"name": "Location",
"hovertext": [[rent],[submarket]],
"showlegend": False,
"hoverinfo": "text",
"mode": "markers",
"marker": {
"symbol": "circle",
"size": 12,
"opacity": 0.7
}
}
)
layout = {
"autosize": True,
"hovermode": "closest",
"title": "Property Map",
"mapbox": {
"accesstoken": MAPBOX_KEY,
"bearing": 0,
"center": {
"lat": 33.4484,
"lon": -112.0740
},
"pitch": 0,
"zoom": 10,
"style": "outdoors",
}
}
return {"data": data, "layout": layout}
I’d like to display the calc_val in mapbox pop up. Popup similar to this: https://docs.mapbox.com/mapbox-gl-js/example/popup/
2 posts - 2 participants