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

Description Usage Arguments Functions Examples

View source: R/extensions.R

Description

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

Usage

1
2
3
4
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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(leaflet)
library(raster)

m <- leaflet() %>%
  addProviderTiles("OpenStreetMap") %>%
  addCircleMarkers(data = breweries) %>%
  addHomeButton(extent(breweries), "breweries")
m

## remove the button
removeHomeButton(m)

r-spatial/mapview documentation built on Nov. 11, 2018, 12:27 p.m.