plot_jpmap() is the right tool for static maps with
Okinawa and Ogasawara insets. Leaflet is different: web tiles expect
true longitude and latitude, so jp_map_leaflet() uses
literal WGS84 geography rather than the inset layout.
Install leaflet before running these examples:
install.packages("leaflet")Prefecture Choropleth
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
)jp_map_leaflet() uses the same data-join logic as
plot_jpmap(). If your data has numeric prefecture codes
such as 1, 2, and 47,
jpmap can still match them to map codes such as
"01", "02", and "47".
Disputed-Territory Layer
For web maps, use territorial_disputes = FALSE to
exclude disputed-territory shapes, or highlight them explicitly.
jp_map_leaflet(
"prefecture",
fill = "grey92",
disputed_fill = "#005BAC",
disputed_color = "#001040",
disputed_dots = TRUE
)Small disputed-territory polygons can be hard to click at a national
zoom level, so disputed_dots = TRUE can add circle markers
when you choose to emphasize them.
Municipal Map
Okinawa municipal data can be used when the corresponding boundary
file is available through jpmapdata or
jpmap_data_dir().
jp_map_leaflet(
"municipality",
include = "Okinawa",
fill = "grey92",
color = "white",
weight = 0.8,
popup = "municipality_ja"
)