## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  eval = FALSE,
  fig.width = 7,
  fig.height = 5
)
jpmap_build_full_vignettes <- identical(tolower(Sys.getenv("JPMAP_FULL_VIGNETTES")), "true") ||
  identical(tolower(Sys.getenv("IN_PKGDOWN")), "true")
jpmap_available_data <- if (jpmap_build_full_vignettes) {
  jpmap::available_jpmap_data()
} else {
  jpmap::available_jpmap_data(data_dir = tempfile())
}
jpmap_has_boundary_data <- nrow(jpmap_available_data) > 0
jpmap_has_okinawa_data <- any(jpmap_available_data$year == 2024 & jpmap_available_data$pref_code == "47")
jpmap_has_leaflet <- requireNamespace("leaflet", quietly = TRUE)

## ----eval = FALSE-------------------------------------------------------------
# install.packages("leaflet")

## ----leaflet-prefecture, eval = jpmap_has_boundary_data && jpmap_has_leaflet----
# library(tidyverse)
# library(jpmap)
# 
# gdp <- jp_prefecture_gdp |>
#   select(pref_code, prefecture, gdp_per_capita_jpy)
# 
# jp_map_leaflet(
#   "prefecture",
#   data = gdp,
#   values = "gdp_per_capita_jpy",
#   palette = "Blues",
#   popup = "prefecture",
#   simplify_tolerance = 0.03
# )

## ----eval = FALSE-------------------------------------------------------------
# jp_map_leaflet(
#   "prefecture",
#   fill = "grey92",
#   disputed_fill = "#005BAC",
#   disputed_color = "#001040",
#   disputed_dots = TRUE
# )

## ----eval = jpmap_has_okinawa_data && jpmap_has_leaflet-----------------------
# jp_map_leaflet(
#   "municipality",
#   include = "Okinawa",
#   fill = "grey92",
#   color = "white",
#   weight = 0.8,
#   popup = "municipality_ja"
# )

## ----eval = FALSE-------------------------------------------------------------
# output$japan_map <- leaflet::renderLeaflet({
#   jp_map_leaflet(
#     "prefecture",
#     data = jp_prefecture_gdp,
#     values = "gdp_per_capita_jpy"
#   )
# })

