Skip to contents

Text Layer

Usage

add_text_layer(
  rdeck,
  ...,
  id = uuid::UUIDgenerate(),
  name = "TextLayer",
  group_name = NULL,
  data = NULL,
  visible = TRUE,
  pickable = FALSE,
  opacity = 1,
  wrap_longitude = FALSE,
  position_format = "XY",
  color_format = "RGBA",
  auto_highlight = FALSE,
  highlight_color = "#00008080",
  billboard = TRUE,
  size_scale = 1,
  size_units = "pixels",
  size_min_pixels = 0,
  size_max_pixels = 9007199254740991,
  background = FALSE,
  get_background_color = "#ffffffff",
  get_border_color = "#000000ff",
  get_border_width = 0,
  background_padding = c(0, 0, 0, 0),
  font_family = "Roboto, Helvetica, Arial, san-serif",
  font_weight = "normal",
  line_height = 1,
  outline_width = 0,
  outline_color = "#000000ff",
  font_settings = list(),
  word_break = "break-word",
  max_width = -1,
  get_text = text,
  get_position = position,
  get_color = "#000000ff",
  get_size = 32,
  get_angle = 0,
  get_text_anchor = "middle",
  get_alignment_baseline = "center",
  get_pixel_offset = c(0, 0),
  blending_mode = "normal",
  visibility_toggle = TRUE,
  tooltip = NULL
)

update_text_layer(
  rdeck,
  ...,
  id,
  name = cur_value(),
  group_name = cur_value(),
  data = cur_value(),
  visible = cur_value(),
  pickable = cur_value(),
  opacity = cur_value(),
  wrap_longitude = cur_value(),
  position_format = cur_value(),
  color_format = cur_value(),
  auto_highlight = cur_value(),
  highlight_color = cur_value(),
  billboard = cur_value(),
  size_scale = cur_value(),
  size_units = cur_value(),
  size_min_pixels = cur_value(),
  size_max_pixels = cur_value(),
  background = cur_value(),
  get_background_color = cur_value(),
  get_border_color = cur_value(),
  get_border_width = cur_value(),
  background_padding = cur_value(),
  font_family = cur_value(),
  font_weight = cur_value(),
  line_height = cur_value(),
  outline_width = cur_value(),
  outline_color = cur_value(),
  font_settings = cur_value(),
  word_break = cur_value(),
  max_width = cur_value(),
  get_text = cur_value(),
  get_position = cur_value(),
  get_color = cur_value(),
  get_size = cur_value(),
  get_angle = cur_value(),
  get_text_anchor = cur_value(),
  get_alignment_baseline = cur_value(),
  get_pixel_offset = cur_value(),
  blending_mode = cur_value(),
  visibility_toggle = cur_value(),
  tooltip = cur_value()
)

Arguments

rdeck

<rdeck | rdeck_proxy> An rdeck map instance.

...

Additional parameters that will be forwarded to deck.gl javascript without validation nor processing. All dots must be named and will be camelCased when serialised. A warning is raised when dots are used, warning class rdeck_dots_nonempty.

id

<string> The layer's identifier must be unique for among all layers of the same type for a map. Defaults to uuid::UUIDgenerate(), but should be explicitly defined for updatable layers in a shiny application.

name

<string> Identifies the layer on tooltips and legends. It does not need to be unique, but should be brief. Defaults to the deck.gl class name for the layer.

group_name

<string> Defines the group that this layer belongs to. Currently only effective on the layer selector, if visibility_toggle = TRUE.

data

<data.frame | sf | string> The layer's data. Data frames and sf objects will contain all columns that are referenced by the layer's accessors. Strings will be interpreted as a URL and data will be retrieved dynamically in the browser.

visible

<boolean> Determines whether the layer is visible or not; also determines whether any legend elements for the layer will be displayed.

pickable

<boolean> Determines if the layer responds to pointer / touch events.

opacity

<number> Determines the layer's opacity.

wrap_longitude

<boolean> Normalises geometry longitudes.

position_format

<"XY" | "XYZ"> Determines whether each coordinate has two (XY) or three (XYZ) elements.

color_format

<"RGB" | "RGBA"> Determines whether the alpha channel of the colours will be ignored by accessors, making all colours opaque.

auto_highlight

<boolean> When TRUE, the current object hovered by the cursor is highlighted by highlight_color.

highlight_color

<accessor | scale | color> When auto_highlight and pickable are enabled, highlight_color determines the colour of the currently highlighted object. If a single colour value is supplied, that colour will be used to highlight all objects in the layer. Per-object highlighting is achieved with a colour scale, or a tidy-eval column of colours.

billboard

<boolean> If TRUE, the text label always faces the camera, otherwise it faces up (z).

size_scale

<number> The size multiplier.

size_units

<"pixels" | "common" | "meters"> The units of the size specified by get_size.

size_min_pixels

<number> The minimum size in pixels.

size_max_pixels

<number> The maximum size in pixels.

background

<boolean> Whether to render background for text labels.

get_background_color

<accessor | scale | color> The text background colour, if background = TRUE. Accepts a single colour value, a colour scale, or a tidy-eval column of colours.

get_border_color

<accessor | scale | color> The text background border colour, if background = TRUE. Accepts a single colour value, a colour scale, or a tidy-eval column of colours.

get_border_width

<accessor | scale | number> The text background border width, if background = TRUE. Accepts a single numeric value, a numeric scale, or a tidy-eval column of numbers.

background_padding

<numeric> The text background padding. Must be an array of 2 or 4 numbers.

font_family

<string> Specifies a prioritised list of one or more font family names. See font-family.

font_weight

<"normal" | "bold" | 100:900> The font weight. See font-weight

line_height

<number> A unitless number that will be multiplied with get_size to set the line height.

outline_width

<number> The text outline width, relative to font size. Requires font_settings$sdf = TRUE.

outline_color

<color> The text outline colour. Requires font_settings$sdf = TRUE.

font_settings

<font_settings> Advanced options for fine tuning the appearance and performance of the generated font_atlas.

word_break

<"break-word" | "break-all"> Requires a valid max_width.

max_width

<number> Used together with word_break for wrapping text. Specifies the width limit to break the text into multiple lines.

get_text

<accessor> The text value of each text label. Accepts a tidy-eval character column of labels.

get_position

<accessor> The feature positions. A <point/multipoint> wk-geometry column with CRS EPSG:4326. Supports tidy-eval.

get_color

<accessor | scale | color> The colour of each object. Accepts a single colour value, a colour scale, or a tidy-eval column of colours.

get_size

<accessor | scale | number> The font size of each text label, in units specified by size_units. Accepts a single numeric value, a numeric scale, or a tidy-eval column of numbers.

get_angle

<accessor | number> The rotating angle of each text label in degrees. Accepts a single numeric value, or a tidy-eval column of numbers.

get_text_anchor

<accessor | "start" | "middle" | "end"> The text label anchor. May be a single value, or a tidy-eval character column.

get_alignment_baseline

<accessor | "top" | "center" | "bottom"> The text label alignment baseline. May be a single value, or a tidy-eval character column.

get_pixel_offset

<accessor | number> The pixel offset for each object. Accepts a single length-2 numeric vector, or a tidy-eval list column.

blending_mode

<"normal" | "additive" | "subtractive"> Sets the blending mode. Blending modes:

  • normal: Normal blending doesn't alter colours of overlapping objects.

  • additive: Additive blending adds colours of overlapping objects. Useful for highlighting dot density on dark maps.

  • subtractive: Subtractive blending darkens overlapping objects. Useful for highlighting dot density on light maps.

visibility_toggle

<boolean> Whether this layer will appear in the layer selector.

tooltip

<tooltip> Defines the columns (and their order) that will be displayed in the layer tooltip, if pickable == TRUE. Supports tidy-select if a data is a data.frame. Geometry columns are always removed.