Learn R Programming

deckgl (version 0.2.5)

add_h3_cluster_layer: Add a h3 cluster layer to the deckgl widget

Description

Add a h3 cluster layer to the deckgl widget

Usage

add_h3_cluster_layer(deckgl, id = "h3-cluster-layer", data = NULL,
  properties = list(), ...)

Arguments

deckgl

deckgl widget

id

id of the layer

data

url to fetch data from or data object

properties

named list of properties with names corresponding to the properties defined in the deckgl-api-reference for the given layer class, additionally there is a getTooltip property (callback) showing a tooltip when the mouse enters an object, e. g. getTooltip = JS("object => object.name")

...

more properties (will be added to the properties object), useful if you want to use a properties object for more than one layer

See Also

https://deck.gl/#/documentation/deckgl-api-reference/layers/h3-cluster-layer

Examples

Run this code
# NOT RUN {
## @knitr h3-cluster-layer
data_url <- paste0(
  "https://raw.githubusercontent.com/uber-common/deck.gl-data/",
  "master/website/sf.h3clusters.json"
)
# sample_data <- jsonlite::fromJSON(data_url, simplifyDataFrame = FALSE)
sample_data <- data_url

properties <- list(
  stroked = TRUE,
  filled = TRUE,
  extruded = FALSE,
  getHexagons = ~hexIds,
  getFillColor = JS("d => [255, (1 - d.mean / 500) * 255, 0]"),
  getLineColor = c(255, 255, 255),
  lineWidthMinPixels = 2,
  getTooltip = ~mean
)

deck <- deckgl(zoom = 10.5, pitch = 20) %>%
  add_h3_cluster_layer(data = sample_data, properties = properties) %>%
  add_mapbox_basemap()

if (interactive()) deck
# }

Run the code above in your browser using DataLab