Learn R Programming

mapgl

The mapgl R package makes the latest versions of Mapbox GL JS and MapLibre GL JS available to R users. The package interface is designed to make the powerful capabilities of both libraries available in R mapping projects, but also feel similar to users coming from other R mapping packages.

Install from CRAN:

install.packages("mapgl")

Or, install the development version from GitHub:

remotes::install_github("walkerke/mapgl")

Read through these vignettes to learn how to use the package:

Recommended training and how to learn more

If you find this project useful in your work and would like to ensure continued development of the package, you can provide support in the following ways:

To stay on top of package updates / new features and to get information about mapgl trainings, be sure to sign up for the Walker Data mailing list here.

Copy Link

Version

Install

install.packages('mapgl')

Monthly Downloads

1,131

Version

0.4.3

License

MIT + file LICENSE

Maintainer

Kyle Walker

Last Published

November 20th, 2025

Functions in mapgl (0.4.3)

add_h3j_source

Add a hexagon source from the H3 geospatial indexing system.
add_layer

Add a layer to a map from a source
add_line_layer

Add a line layer to a map
add_layers_control

Add a layers control to the map
add_globe_minimap

Add a Globe Minimap to a map
add_heatmap_layer

Add a heatmap layer to a Mapbox GL map
add_raster_layer

Add a raster layer to a Mapbox GL map
add_source

Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map
add_pmtiles_source

Add a PMTiles source to a Mapbox GL or Maplibre GL map
add_video_source

Add a video source to a Mapbox GL or Maplibre GL map
add_reset_control

Add a reset control to a map
add_vector_source

Add a vector tile source to a Mapbox GL or Maplibre GL map
add_raster_source

Add a raster tile source to a Mapbox GL or Maplibre GL map
add_raster_dem_source

Add a raster DEM source to a Mapbox GL or Maplibre GL map
add_scale_control

Add a scale control to a map
add_symbol_layer

Add a symbol layer to a map
clear_legend

Clear legends from a map
clear_drawn_features

Clear all drawn features from a map
add_view

Add a visualization layer to an existing map
clear_layer

Clear layers from a map using a proxy
cluster_options

Prepare cluster options for circle layers
carto_style

Get CARTO Style URL
clear_controls

Clear controls from a Mapbox GL or Maplibre GL map in a Shiny app
compare

Create a Compare widget
classification_helpers

Extract information from classification and continuous scale objects
fly_to

Fly to a given view
format_numbers

Format numbers for legend labels
concat

Create a concatenation expression
clear_markers

Clear markers from a map in a Shiny session
get_column

Get column or property for use in mapping
get_drawn_features

Get drawn features from the map
interpolate

Create an interpolation expression
mapboxgl_compare_proxy

Create a proxy object for a Mapbox GL Compare widget in Shiny
fit_bounds

Fit the map to a bounding box
jump_to

Jump to a given view
get_queried_features

Get queried features from a map as an sf object
enable_shiny_hover

Enable hover events for Shiny applications
mapboxgl

Initialize a Mapbox GL Map
mapbox_style

Get Mapbox Style URL
interpolate_palette

Create an interpolation expression with automatic palette and break calculation
mapboxgl_proxy

Create a proxy object for a Mapbox GL map in Shiny
mapboxglCompareOutput

Create a Mapbox GL Compare output element for Shiny
mapboxglOutput

Create a Mapbox GL output element for Shiny
ease_to

Ease to a given view
legend_style

Create custom styling for map legends
map_legends

Add legends to Mapbox GL and MapLibre GL maps
maplibre

Initialize a Maplibre GL Map
mapgl-package

mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS'
maplibre_view

Quick visualization of geometries with MapLibre GL
maplibre_compare_proxy

Create a proxy object for a Maplibre GL Compare widget in Shiny
maplibre_proxy

Create a proxy object for a Maplibre GL map in Shiny
match_expr

Create a match expression
maplibreOutput

Create a Maplibre GL output element for Shiny
mapboxgl_view

Quick visualization of geometries with Mapbox GL
maplibreCompareOutput

Create a Maplibre GL Compare output element for Shiny
maptiler_style

Get MapTiler Style URL
on_section

Observe events on story map section transitions
renderMapboxglCompare

Render a Mapbox GL Compare output element in Shiny
renderMaplibre

Render a Maplibre GL output element in Shiny
move_layer

Move a layer to a different z-position
openfreemap_style

Get OpenFreeMap Style URL
number_format

Create a number formatting expression
renderMapboxgl

Render a Mapbox GL output element in Shiny
query_rendered_features

Query rendered features on a map in a Shiny session
palette_to_lut

Convert R color palette to mapgl LUT
renderMaplibreCompare

Render a Maplibre GL Compare output element in Shiny
set_popup

Set popup on a map layer
set_paint_property

Set a paint property on a map layer
set_rain

Set rain effect on a Mapbox GL map
set_snow

Set snow effect on a Mapbox GL map
set_projection

Set Projection for a Mapbox/Maplibre Map
set_filter

Set a filter on a map layer
set_config_property

Set a configuration property for a Mapbox GL map
story_leaflet

Create a scrollytelling story map with Leaflet
story_map

Create a scrollytelling story map
set_style

Update the style of a map
set_terrain

Set terrain properties on a map
set_layout_property

Set a layout property on a map layer
set_fog

Set fog on a Mapbox GL map
step_classification

Step expressions with automatic classification
turf_buffer

Turf.js Geospatial Operations for mapgl
step_expr

Create a step expression
turf_center_of_mass

Calculate center of mass
turf_centroid

Calculate centroid of geometries
story_section

Create a story section for story maps
story_maplibre

Create a scrollytelling story map with MapLibre
turf_area

Calculate area of geometries
turf_filter

Spatial filter features by predicate
turf_voronoi

Create Voronoi diagram
turf_union

Union geometries
turf_intersect

Find intersection of two geometries
turf_difference

Find difference between two geometries
set_view

Set the map center and zoom level
turf_distance

Calculate distance between two features
set_source

Set source of a map layer
turf_concave_hull

Create concave hull
set_tooltip

Set tooltip on a map layer
turf_convex_hull

Create convex hull
add_fill_layer

Add a fill layer to a map
add_geocoder_control

Add a geocoder control to a map
add_fullscreen_control

Add a fullscreen control to a map
add_fill_extrusion_layer

Add a fill-extrusion layer to a Mapbox GL map
add_features_to_draw

Add features to an existing draw control
add_draw_control

Add a draw control to a map
add_circle_layer

Add a circle layer to a Mapbox GL map
add_control

Add a custom control to a map
add_image

Add an image to the map
add_geolocate_control

Add a geolocate control to a map
add_globe_control

Add a globe control to a map
add_navigation_control

Add a navigation control to a map
add_markers

Add markers to a Mapbox GL or Maplibre GL map
add_image_source

Add an image source to a Mapbox GL or Maplibre GL map