R/raster-tiles.R

Defines functions raster_tile_properties add_raster_tile_layer

Documented in add_raster_tile_layer

### TODO: Remove in next version
###
#' Add a raster tile layer to the deckgl widget
#'
#' EXPERIMENTAL, see \url{https://deck.gl/#/examples/core-layers/tile-layer}
#'
#' @inheritParams add_layer
#' @param tileServer base url of the tile server
#' @example inst/examples/deckgl-api-reference/raster-tile-layer.R
#' @export
add_raster_tile_layer <- function(
  deckgl,
  id = "raster-tiles",
  tileServer = "https://c.tile.openstreetmap.org/",
  properties = list(),
  ...
) {
  properties <- utils::modifyList(raster_tile_properties(tileServer), properties)
  add_layer(deckgl, "TileLayer", id, data = NULL, properties = properties, ...)
}

raster_tile_properties <- function(tile_server) {
  list(
    opacity = 1,
    minZoom = 0,
    maxZoom = 19,
    tileServer = tile_server,
    renderSubLayers = JS("deckglWidget.renderMapTiles")
  )
}

Try the deckgl package in your browser

Any scripts or data that you put into this service are public.

deckgl documentation built on March 7, 2023, 5:37 p.m.