add_control {mapgl} | R Documentation |
Add a custom control to a map
Description
This function adds a custom control to a Mapbox GL or MapLibre GL map. It allows you to create custom HTML element controls and add them to the map.
Usage
add_control(map, html, position = "top-right", className = NULL, ...)
Arguments
map |
A map object created by the |
html |
Character string containing the HTML content for the control. |
position |
The position of the control. Can be one of "top-left", "top-right", "bottom-left", or "bottom-right". Default is "top-right". |
className |
Optional CSS class name for the control container. |
... |
Additional arguments passed to the JavaScript side. |
Value
The modified map object with the custom control added.
Examples
## Not run:
library(mapgl)
maplibre() |>
add_control(
html = "<div style='background-color: white; padding: 5px;'>
<p>Custom HTML</p>
<img src='path/to/image.png' alt='image'/>
</div>",
position = "top-left"
)
## End(Not run)
[Package mapgl version 0.3.2 Index]