Adds polygons to the map from a mesh3d object

  data = get_map_data(map),
  fill_opacity = NULL,
  elevation = NULL,
  tooltip = NULL,
  auto_highlight = FALSE,
  highlight_colour = "#AAFFFFFF",
  light_settings = list(),
  layer_id = NULL,
  id = NULL,
  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



a mapdeck map object


data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system


Either a string specifying the column of data containing the opacity of each shape, or a single value in [0,255], or [0, 1), to be applied to all the shapes. Default 255. If a hex-string is used as the colour, this argument is ignored and you should include the alpha on the hex string


the height the polygon extrudes from the map. Only available if neither stroke_colour or stroke_width are supplied. Default 0


variable of data containing text or HTML to render as a tooltip


logical indicating if the shape under the mouse should auto-highlight


hex string colour to use for highlighting. Must contain the alpha component.


list of light setting parameters. See light_settings


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


an id value in data to identify layers when interacting in Shiny apps.


string or matrix. String will be one of colourvalues::colour_palettes(). A matrix must have at least 5 rows, and 3 or 4 columns of values between [0, 255], where the 4th column represents the alpha. You can use a named list to specify a different palette for different colour options (where available), e.g. list(fill_colour = "viridis", stroke_colour = "inferno")


hex string colour to use for NA values


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.


A list of options for controlling the legend.


A list containing functions to apply to legend values. See section legend


logical indicating if the map should update the bounds to include this layer


logical indicating if the map should update the bounds to only include this layer


number of digits for rounding coordinates


list specifying the duration of transitions.


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


add_mesh supports mesh3d objects


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 legend

  • title - 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.


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


# \donttest{ ## exaggerate the elevation slightly m <- melbourne_mesh m$vb[3, ] <- m$vb[3, ] * 50 mapdeck() %>% add_mesh( data = m )
#> mesh is an experimental layer and the function may change without warning
#> default
# }