add_zoom: Add zoom capacity

Description Usage Arguments Note Examples

Description

Add zoom capacity

Usage

1
add_zoom(map, enabled = TRUE, type = "click")

Arguments

map

A r2d3map htmlwidget object.

enabled

Logical, enable zooming.

type

Type of zoom: "click" for zooming to clicked polygon, or "wheel" for zooming with mouse wheel. Both can be supplied.

Note

Zoom with mousewheel doesn't work in RStudio viewer. Zooming can be slow for a map with lot of polygons.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library( r2d3maps )
library( rnaturalearth )


turkey <- ne_states(country = "turkey", returnclass = "sf")
d3_map(shape = turkey)

# zoom with click
d3_map(shape = turkey) %>% add_zoom()

# zoom with mousewheel (open in browser)
d3_map(shape = turkey) %>% add_zoom(type = "wheel")

dreamRs/r2d3maps documentation built on May 25, 2019, 8:17 a.m.