Different behavior: st.map & st.deck_gl_chart

Can anyone tell me how to use st.deck_gl_chart correctly? I think I’ve followed the documentation but cannot see my data. I’m using VS Code and Chrome on Windows 10 with Python 3.7 Anaconda 64bit.

data with “lat” and “lon” column

df = pd.read_csv(“path\to\data.csv”)

displays and zooms correctly to data

st.map(df)

displays map, unzoomed, without data

st.deck_gl_chart(layers = [{‘data’: df,‘type’: ‘ScatterplotLayer’}])

Hi @davideps,

Welcome to the forum :wave:

Here’s an example of using st.deck_gl_chart

import streamlit as st
import numpy as np
import pandas as pd

data = np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4]
df = pd.DataFrame(data, columns=["lat", "lon"])

viewport = {"latitude": 37.76, "longitude": -122.4, "zoom": 11, "pitch": 50}
layers = [{"data": df, "type": "ScatterplotLayer"}]

st.deck_gl_chart(viewport=viewport, layers=layers)

Thank you Jonathan. That works. I didn’t realize the viewport was required.

1 Like