SymbolixAU / mapdeck
1
#' Add Title
2
#'
3
#' Adds a title to a map
4
#'
5
#' @inheritParams add_arc
6
#' @param title Either a single string for the title, or a list with a 'title' element,
7
#' and an optional 'css' element. See examples
8
#'
9
#' @examples
10
#' \donttest{
11
#'
12
#' mapdeck() %>%
13
#'   add_title(title = "first title", layer_id = "first") %>%
14
#'   add_title(title = list(
15
#'       title = "second title",
16
#'       css = "background-color: red;"),
17
#'     layer_id = "second") %>%
18
#'   add_title(title = list(
19
#'       title = "Another title",
20
#'       css = "background-color: transparent;"),
21
#'     layer_id = "third")
22
#'
23
#' }
24
#'
25
#' @export
26
add_title <- function(map, title, layer_id = NULL) {
27

28 0
	layer_id <- layerId( layer_id, layer = "title" )
29 0
	if(!inherits(title, "list")) title <- list(title = title)
30

31 0
	invoke_method(map, "add_title", map_type( map ), layer_id, jsonify::to_json( title, unbox = TRUE ) )
32
}
33

34

35
#' @rdname clear
36
#' @export
37
clear_title <- function(map, layer_id = NULL ) {
38 0
	layer_id <- layerId( layer_id, layer = "title")
39 0
	invoke_method(map, "clear_title", map_type( map ), layer_id)
40
}

Read our documentation on viewing source code .

Loading