Display a map with a scatterplot overlaid onto it. This is a wrapper around ``st.pydeck_chart`` to quickly create scatterplot charts on top of a map, with auto-centering and auto-zoom. When using this command, a service called Carto_ provides the map tiles to render
(
self,
data: Data = None,
*,
latitude: str | None = None,
longitude: str | None = None,
color: str | Color | None = None,
size: str | float | None = None,
zoom: int | None = None,
width: WidthWithoutContent = "stretch",
height: HeightWithoutContent = 500,
use_container_width: bool | None = None,
)
| 86 | class MapMixin: |
| 87 | @gather_metrics("map") |
| 88 | def map( |
| 89 | self, |
| 90 | data: Data = None, |
| 91 | *, |
| 92 | latitude: str | None = None, |
| 93 | longitude: str | None = None, |
| 94 | color: str | Color | None = None, |
| 95 | size: str | float | None = None, |
| 96 | zoom: int | None = None, |
| 97 | width: WidthWithoutContent = "stretch", |
| 98 | height: HeightWithoutContent = 500, |
| 99 | use_container_width: bool | None = None, |
| 100 | ) -> DeltaGenerator: |
| 101 | """Display a map with a scatterplot overlaid onto it. |
| 102 | |
| 103 | This is a wrapper around ``st.pydeck_chart`` to quickly create |
| 104 | scatterplot charts on top of a map, with auto-centering and auto-zoom. |
| 105 | |
| 106 | When using this command, a service called Carto_ provides the map tiles to render |
| 107 | map content. If you're using advanced PyDeck features you may need to obtain |
| 108 | an API key from Carto first. You can do that as |
| 109 | ``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY |
| 110 | environment variable. See `PyDeck's documentation`_ for more information. |
| 111 | |
| 112 | Another common provider for map tiles is Mapbox_. If you prefer to use that, |
| 113 | you'll need to create an account at https://mapbox.com and specify your Mapbox |
| 114 | key when creating the ``pydeck.Deck`` object. You can do that as |
| 115 | ``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY |
| 116 | environment variable. |
| 117 | |
| 118 | .. _Carto: https://carto.com |
| 119 | .. _Mapbox: https://mapbox.com |
| 120 | .. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html |
| 121 | |
| 122 | Carto and Mapbox are third-party products and Streamlit accepts no responsibility |
| 123 | or liability of any kind for Carto or Mapbox, or for any content or information |
| 124 | made available by Carto or Mapbox. The use of Carto or Mapbox is governed by |
| 125 | their respective Terms of Use. |
| 126 | |
| 127 | Parameters |
| 128 | ---------- |
| 129 | data : Anything supported by st.dataframe |
| 130 | The data to be plotted. |
| 131 | |
| 132 | latitude : str or None |
| 133 | The name of the column containing the latitude coordinates of |
| 134 | the datapoints in the chart. |
| 135 | |
| 136 | If None, the latitude data will come from any column named 'lat', |
| 137 | 'latitude', 'LAT', or 'LATITUDE'. |
| 138 | |
| 139 | longitude : str or None |
| 140 | The name of the column containing the longitude coordinates of |
| 141 | the datapoints in the chart. |
| 142 | |
| 143 | If None, the longitude data will come from any column named 'lon', |
| 144 | 'longitude', 'LON', or 'LONGITUDE'. |
| 145 |