Black Lives Matter. Please consider donating to Black Girls Code today.

Search Bar Mapbox Choropleth

I’ve made a custom choropleth map in Dash but I’d like to add a search bar which zooms in on an address. I’d also like to then add a click event where if you click on an address it redirects you to another page which provides relevant information about the building. Is this possible and if so can someone point me in the right direction?

You should be able to zoom into regions by returning a new figure with something like:

@app.callback(...)
def update_figure(...):
    ...
    {
        'data': [{'lat': [...], 'lon': [...], 'type': 'scattermapbox'}],
        'layout': {
            'mapbox': { see https://plot.ly/python/reference/#layout-mapbox for all options
                'zoom': 7,
                'center': {'lon': ..., 'lat': ...}
            }
        }
    }

Unfortunately, click events aren’t supported for geojson yet. One workaround is to draw scatter points on top of the choropleth shapes and listen to click events of those points (with https://plot.ly/dash/interactive-graphing).
We would like to expand our functionality here - if you or your company would like to sponsor this work, please reach out: https://plot.ly/products/consulting-and-oem/