/
controls.R
33 lines (28 loc) · 1.05 KB
/
controls.R
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
28
29
30
31
32
33
#' @param html the content of the control. May be provided as string or as HTML
#' generated with Shiny/htmltools tags
#' @param position position of control: `"topleft"`, `"topright"`,
#' `"bottomleft"`, or `"bottomright"`.
#' @param className extra CSS classes to append to the control, space separated
#'
#' @describeIn map-layers Add arbitrary HTML controls to the map
#' @export
addControl <- function(
map, html, position = c("topleft", "topright", "bottomleft", "bottomright"),
layerId = NULL, className = "info legend", data = getMapData(map)
) {
position <- match.arg(position)
deps <- htmltools::resolveDependencies(htmltools::findDependencies(html))
html <- as.character(html)
map$dependencies <- c(map$dependencies, deps)
invokeMethod(map, data, "addControl", html, position, layerId, className)
}
#' @export
#' @rdname remove
removeControl <- function(map, layerId) {
invokeMethod(map, NULL, "removeControl", layerId)
}
#' @export
#' @rdname remove
clearControls <- function(map) {
invokeMethod(map, NULL, "clearControls")
}