walkerke / mapgl

R interface to Mapbox GL JS v3 and Maplibre GL JS
https://walker-data.com/mapgl
Other
91 stars 5 forks source link

Add Source issue for set terrain #47

Closed sailbot24 closed 1 month ago

sailbot24 commented 1 month ago

the example provided in the set terrain documentaion -

map <- mapboxgl(style = "mapbox://styles/mapbox/satellite-streets-v12", center = c(-111.658106, 40.582623), zoom = 10, pitch = 45, bearing = 180)

map <- add_source(map, id = "mapbox-dem", type = "raster-dem", url = "mapbox://mapbox.mapbox-terrain-dem-v1", tileSize = 512, maxzoom = 14)

map <- set_terrain(map, source = "mapbox-dem", exaggeration = 1.5)

leads to this error - Error in add_source(map, id = "mapbox-dem", type = "raster-dem", url = "mapbox://mapbox.mapbox-terrain-dem-v1", : argument "data" is missing, with no default

walkerke commented 1 month ago

Thanks for the catch! I've updated the docs. Try out the updated example:

library(mapgl)

mapboxgl(
  style = mapbox_style("standard-satellite"),
  center = c(-114.26608, 32.7213),
  zoom = 14,
  pitch = 80,
  bearing = 41
) |> 
  add_raster_dem_source(
    id = "mapbox-dem",
    url = "mapbox://mapbox.mapbox-terrain-dem-v1",
    tileSize = 512, 
    maxzoom = 14
  ) |> 
  set_terrain(
    source = "mapbox-dem", 
    exaggeration = 1.5
  )