Skip to contents

Add a data source to a mapgl::maplibre() or mapgl::mapboxgl() map.

Usage

addSource(map, id, data, file, url, ...)

Arguments

map

the mapgl::maplibre() or mapgl::mapboxgl() map to add the data source to.

id

a unique ID for the data source.

data

a sf, wk, geos or SpatVector object.

file

a valid local file path to a geoarrow or geoparquet file to be added to the map. Ignored if data is supplied.

url

a URL to a remotely hosted geoarrow or geoparquet file to be added to the map. Ignored if data or file is supplied.

...

currently not used.

Value

The modified map object with the added data source attached.

Details

See geoarrowWidget::attachData() for details.

Examples

library(mapgl)
library(wk)

pt = wkt("POINT (0 0)")

m = maplibre()

m = m |>
  addSource(
    id = "pt"
    , data = pt
  ) |>
  addGeoArrowScatterplotLayer(source = "pt")

## open the map in the browser, press <Ctrl+u> and look for a line like this:
## <link id="pt-geoarrowWidget-attachment" rel="attachment" href="lib/pt-0.0.1/pt.arrow"/>
m