Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

updateLayersControl

Update the layer controls when adding layers to an existing map.


Description

When adding additional base layers or overlay layers to an existing map, updateLayersControl will either update the existing layers control or add a new one if map has none.

Usage

updateLayersControl(
  map,
  addBaseGroups = character(0),
  addOverlayGroups = character(0),
  position = "topleft",
  ...
)

Arguments

map

A leaflet or mapview map.

addBaseGroups

group names of base layers to be added to layers control.

addOverlayGroups

group names of overlay layers to be added to layers control.

position

position of control: "topleft", "topright", "bottomleft", or "bottomright".

...

Further arguments passed to addLayersControl.

Value

A leaflet map object.

Examples

library(leaflet)

map = leaflet() %>%
        addProviderTiles("OpenStreetMap", group = "OSM") %>%
        addProviderTiles("CartoDB.DarkMatter", group = "dark") %>%
        addCircleMarkers(data = breweries91, group = "brew")

map # no layers control

map %>%
  updateLayersControl(addBaseGroups = c("OSM", "dark"),
                      addOverlayGroups = "brew")

leafem

'leaflet' Extensions for 'mapview'

v0.1.3
MIT + file LICENSE
Authors
Tim Appelhans [cre, aut], Christoph Reudenbach [ctb], Kenton Russell [ctb], Jochen Darley [ctb], Daniel Montague [ctb] (Leaflet.EasyButton plugin), Lorenzo Busetto [ctb], Luigi Ranghetti [ctb], Miles McBain [ctb], Sebastian Gatscha [ctb], Björn Harrtell [ctb] (FlatGeobuf plugin), Daniel Dufour [ctb] (georaster-layer-for-leaflet)
Initial release
2020-07-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.