add_layer: Add a layer to the map

Description Usage Arguments See Also Examples

View source: R/layers.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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

crazycapivara/mapboxer documentation built on Nov. 13, 2021, 3:22 a.m.