add_layer {mapboxer}R Documentation

Add a layer to the map

Description

Adds any kind of layer to the map. The type of the layer is specified by the type property of the layer definintion.

Usage

add_layer(map, style, popup = NULL)

Arguments

map

A mapboxer object.

style

A named list that defines the style of the layer. See https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/ for available style options for the used layer type.

popup

A mustache template in which the tags refer to the properties of the layer's data object.

See Also

add_popups for an example of a mustache template used to generate the popup text.

Examples

image_src <- mapbox_source(
  type = "image",
  url = "https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif",
  coordinates = list(
    c(-80.425, 46.437),
    c(-71.516, 46.437),
    c(-71.516, 37.936),
    c(-80.425, 37.936)
  )
)

raster_style <- list(
  id = "overlay",
  type = "raster",
  source = image_src,
  paint = list(
    "raster-opacity" = 0.85
  )
)

map <- mapboxer(
  center = c(-75.789, 41.874),
  zoom = 5
) %>%
  add_layer(raster_style)

if (interactive()) map

[Package mapboxer version 0.4.0 Index]