add_text {mapdeck} | R Documentation |
Add Text
Description
The Text Layer renders text labels on the map
Usage
add_text(
map,
data = get_map_data(map),
text,
lon = NULL,
lat = NULL,
polyline = NULL,
fill_colour = NULL,
fill_opacity = NULL,
size = NULL,
angle = NULL,
anchor = NULL,
alignment_baseline = NULL,
billboard = TRUE,
font_family = "Monaco, monospace",
font_weight = "normal",
tooltip = NULL,
layer_id = NULL,
id = NULL,
auto_highlight = FALSE,
highlight_colour = "#AAFFFFFF",
palette = "viridis",
na_colour = "#808080FF",
legend = FALSE,
legend_options = NULL,
legend_format = NULL,
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL,
brush_radius = NULL,
collision_filter = FALSE,
...
)
Arguments
map |
a mapdeck map object |
data |
data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system |
text |
column of |
lon |
column containing longitude values |
lat |
column containing latitude values |
polyline |
optional column of |
fill_colour |
column of |
fill_opacity |
Either a string specifying the column of |
size |
column of |
angle |
column of |
anchor |
column of |
alignment_baseline |
column of |
billboard |
logical indicating if the text always faces the camera (TRUE) or if it always faces up (FALSE) |
font_family |
specifies a prioritised list of one or more font family names and/or generic family names. Follow the specifics for CSS font-family https://developer.mozilla.org/en-US/docs/Web/CSS/font-family |
font_weight |
specifies the font weight. Follow the specifics for CSS font-weight https://htmldog.com/references/css/properties/font-weight/ |
tooltip |
variable of |
layer_id |
single value specifying an id for the layer. Use this value to distinguish between shape layers of the same type. Layers with the same id are likely to conflict and not plot correctly |
id |
an id value in |
auto_highlight |
logical indicating if the shape under the mouse should auto-highlight |
highlight_colour |
hex string colour to use for highlighting. Must contain the alpha component. |
palette |
string or matrix. String will be one of |
na_colour |
hex string colour to use for NA values |
legend |
either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend. |
legend_options |
A list of options for controlling the legend. |
legend_format |
A list containing functions to apply to legend values. See section legend |
update_view |
logical indicating if the map should update the bounds to include this layer |
focus_layer |
logical indicating if the map should update the bounds to only include this layer |
digits |
number of digits for rounding coordinates |
transitions |
list specifying the duration of transitions. |
brush_radius |
radius of the brush in metres. Default NULL. If supplied, the arcs will only show if the origin or destination are within the radius of the mouse. If NULL, all arcs are displayed |
collision_filter |
set to 'TRUE' if you want to hide features that overlap other features. Default is 'FALSE' |
... |
|
Details
add_text
supports POINT and MULTIPOINT sf objects
transitions
The transitions argument lets you specify the time it will take for the shapes to transition from one state to the next. Only works in an interactive environment (Shiny) and on WebGL-2 supported browsers and hardware.
The time is in milliseconds
Available transitions for text
list( position = 0, fill_colour = 0, angle = 0, size = 0 )
legend
The legend_options
can be used to control the appearance of the legend.
This should be a named list, where the names are one of
css - a string of valid
css
for controlling the appearance of the legendtitle - a string to use for the title of the legend
digits - number to round the legend values to
If the layer allows different fill and stroke colours, you can use different options for each. See examples in add_arc.
The legend_format
can be used to control the format of the values in the legend.
This should be a named list, where the names are one of
fill_colour
stroke_colour
depending on which type of colouring the layer supports.
The list elements must be functions to apply to the values in the legend.
id
The id
is returned to your R session from an interactive shiny environment
by observing layer clicks. This is useful for returning the data.frame row relating to the
cliked shape.
From within a shiny server you would typically use observeEvent({input$map_arc_click})
,
where 'map' is the map_id supplied to mapdeckOutput()
, and 'arc' is the layer
you are clicking on
Examples
## You need a valid access token from Mapbox
key <- 'abc'
set_token( key )
mapdeck(
style = mapdeck_style('dark')
) %>%
add_text(
data = capitals
, lon = 'lon'
, lat = 'lat'
, fill_colour = 'country'
, text = 'capital'
, layer_id = 'text'
)