---
title: "Dragmap demo"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Dragmap demo}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```
This short video shows the core `dragmapr` loop on an actual map: open the
draggable helper, move regions and labels, and use the exported state to create
a reproducible static map.
```{r demo-video, echo = FALSE, results = "asis"}
in_pkgdown <- identical(Sys.getenv("IN_PKGDOWN"), "true") ||
isTRUE(getOption("pkgdown.in_pkgdown"))
if (in_pkgdown) {
cat('
')
} else {
cat("[Watch the dragmap demo video on the pkgdown site](https://prigasg.github.io/dragmapr/articles/dragmap-demo.html).")
}
```
The same workflow can be run locally with the bundled examples:
```{r, eval = FALSE}
library(dragmapr)
hhs <- example_hhs_layout()
drag_map_prototype(
hhs$states,
region_col = "hhs_region",
labels = hhs$labels,
region_offsets = hhs$region_offsets,
label_offsets = hhs$label_offsets,
region_palette = hhs$region_colors,
open = TRUE
)
render_dragged_map(
hhs$states,
region_offsets = hhs$region_offsets,
region_col = "hhs_region",
labels = hhs$labels,
label_offsets = hhs$label_offsets,
region_palette = hhs$region_colors,
region_labels = hhs$region_names,
title = "US Map by HHS Regions"
)
```