Registers a glTF or GLB model with the map so that add_model_layer() can
draw it. Mapbox GL JS only; MapLibre has no model layer.
Arguments
- map
A map object created by
mapboxgl(), or a proxy created bymapboxgl_proxy().- id
A string; the model ID that
model_idinadd_model_layer()refers to.- url
The URL of a
.glbor.gltffile, or the path to a local.glbfile, which is embedded in the map as a data URI. A local.gltffile that refers to external buffers or textures can't be embedded; convert it to.glbfirst.
Examples
if (FALSE) { # \dontrun{
library(mapgl)
turbines <- sf::st_as_sf(
data.frame(lon = c(-100.40, -100.41), lat = c(32.30, 32.31)),
coords = c("lon", "lat"), crs = 4326
)
mapboxgl(center = c(-100.405, 32.305), zoom = 15, pitch = 70) |>
add_model("turbine", "turbine.glb") |>
add_model_layer("turbines", turbines, model_id = "turbine")
} # }
