---
title: "Interactive maps"
output: rmarkdown::html_vignette
author: "Richard Aubrey White, Chi Zhang"
date: "2021-01-15"
vignette: >
  %\VignetteIndexEntry{Interactive maps}
  %\VignetteEncoding{UTF-8}
  %\VignetteEngine{knitr::rmarkdown}
editor_options: 
  chunk_output_type: console
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(ggplot2)
library(data.table)
library(magrittr)
```

## `sf` for interactive maps

Every map also ships as an `sf` object, which pairs with the `leaflet` package
to make interactive, zoomable maps. The example below draws the counties over a
light background tile.

```{r fig.height=6, fig.width=6}
pd_county <- csmaps::nor_county_map_b2024_default_sf
leaflet::leaflet(
  pd_county,
  options = leaflet::leafletOptions(preferCanvas = F)
) %>%
  leaflet::addProviderTiles(leaflet::providers$Esri.WorldGrayCanvas) %>%
  leaflet::addPolygons(
    weight = 0.3,
    opacity = 1,
    color = "black", 
    fillColor = "white",
    fillOpacity = 0.9
  )
```

