Learn R Programming

mapview (version 2.2.0)

addHomeButton: Add a home button / zoom-to-layer button to a map.

Description

This function adds a button to the map that enables zooming to a provided extent / bbox.

Use removeHomeButton to remove home button

Usage

addHomeButton(map, ext, layer.name = "layer", position = "bottomright",
  add = TRUE)

removeHomeButton(map)

Arguments

map

a mapview or leaflet object.

ext

the extent / bbox to zoom to.

layer.name

the name of the layer to be zoomed to (or any character string)

position

the position of the button (one of 'topleft', 'topright', 'bottomleft', 'bottomright'). Defaults to 'bottomright'.

add

logical. Whether to add the button to the map (mainly for internal use).

Functions

  • removeHomeButton: remove a homeButton from a map

Examples

Run this code
# NOT RUN {
library(raster)

m <- leaflet() %>% addTiles() %>% addCircleMarkers(data = breweries91) %>%
  addHomeButton(extent(breweries91), "breweries91")
m

## remove the button
removeHomeButton(m)
# }
# NOT RUN {

# }

Run the code above in your browser using DataLab