Context Components that Help Readers Understand 'mapgl' Maps

Adds components to 'mapgl' maps ('MapLibre GL JS' and 'Mapbox GL JS') that put what the reader sees in context: a live summary of the features in view compared with the whole map, a ranking of the features in view, a tooltip that shows where each value stands among all of them, a search box over the map's own data, notes on the data and its sources, and an animation that lifts the map's shapes into a grid sorted by their values. Everything runs in the browser, so the components work in static HTML, 'R Markdown' and 'Quarto' documents without a 'Shiny' server.


maplore

maplore adds components to mapgl maps that help readers understand what they are looking at: as they pan and zoom, the map tells them how the area in view compares with the rest.

Animated map of Argentina colored by projected population growth. As the map is panned and zoomed, the summary panel on the left and the ranking on the right update with the departments in view, and hovering over a department shows a tooltip with its rank and its difference with the average

  • add_view_summary(): what is in view, compared with the whole map.
  • add_view_ranking(): which features stand out in view.
  • add_context_tooltip(): whether a value is high or low, and its rank.
  • add_feature_search(): find a place in your own data.

maplore is an R package: you use it from R, and its interactive components are written in JavaScript and run in the browser. That is why it works in HTML pages, R Markdown and Quarto documents and dashboards, with no Shiny server.

Installation

# install.packages("pak")
pak::pak("JMTocho/maplore")

Example

library(mapgl)
library(maplore)

maplibre(center = c(-64, -38.5), zoom = 3.4) |>
  add_fill_layer(
    id = "departments",
    source = ar_departments,
    fill_color = interpolate(
      column = "growth",
      values = c(-10, 0, 10),
      stops = c("#b2182b", "#f7f7f7", "#2166ac"),
      na_color = "#d9d9d9"
    )
  ) |>
  add_view_summary("departments", "growth", name_column = "department", suffix = "%") |>
  add_context_tooltip("departments", "growth", name_column = "department", suffix = "%")

Learn more

The website explains each component, the included datasets and how maplore works.

maplore is experimental, and its functions may still change. Feedback and bug reports are welcome in the issues.

Much of the code was written with the help of an AI assistant (Claude, by Anthropic) and reviewed, tested and checked against independent calculations in R.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("maplore")

0.1.0 by Juan Manuel Tocho, 7 hours ago


https://jmtocho.github.io/maplore/, https://github.com/JMTocho/maplore


Report a bug at https://github.com/JMTocho/maplore/issues


Browse source code at https://github.com/cran/maplore


Authors: Juan Manuel Tocho [aut, cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports htmltools, htmlwidgets, jsonlite

Suggests mapgl, sf, testthat


See at CRAN