Title: | An R Interface to 'Mapbox GL JS' |
---|---|
Description: | Makes 'Mapbox GL JS' <https://docs.mapbox.com/mapbox-gl-js/api/>, an open source JavaScript library that uses WebGL to render interactive maps, available within R via the 'htmlwidgets' package. Visualizations can be used from the R console, in R Markdown documents and in Shiny apps. |
Authors: | Stefan Kuethe [aut, cre] |
Maintainer: | Stefan Kuethe <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.2 |
Built: | 2025-02-14 05:12:10 UTC |
Source: | https://github.com/crazycapivara/mapboxer |
Add a circle layer to the map
add_circle_layer(map, source = NULL, filter = NULL, circle_blur = NULL, circle_color = NULL, circle_opacity = NULL, circle_pitch_alignment = NULL, circle_pitch_scale = NULL, circle_radius = NULL, circle_sort_key = NULL, circle_stroke_color = NULL, circle_stroke_opacity = NULL, circle_stroke_width = NULL, circle_translate = NULL, circle_translate_anchor = NULL, visibility = TRUE, popup = NULL, id = "circle-layer")
add_circle_layer(map, source = NULL, filter = NULL, circle_blur = NULL, circle_color = NULL, circle_opacity = NULL, circle_pitch_alignment = NULL, circle_pitch_scale = NULL, circle_radius = NULL, circle_sort_key = NULL, circle_stroke_color = NULL, circle_stroke_opacity = NULL, circle_stroke_width = NULL, circle_translate = NULL, circle_translate_anchor = NULL, visibility = TRUE, popup = NULL, id = "circle-layer")
map |
A mapboxer object. |
source |
A Mapbox source. Uses the source from the mapboxer object if no source is supplied. |
filter |
A filter expression that is applied to the |
circle_blur |
(paint) Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity. |
circle_color |
(paint) The fill color of the circle. |
circle_opacity |
(paint) The opacity at which the circle will be drawn. |
circle_pitch_alignment |
(paint) Orientation of circle when map is pitched. One of "map", "viewport". |
circle_pitch_scale |
(paint) Controls the scaling behavior of the circle when the map is pitched. One of "map", "viewport". |
circle_radius |
(paint) The radius of the circle. |
circle_sort_key |
(layout) Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. |
circle_stroke_color |
(paint) The stroke color of the circle. |
circle_stroke_opacity |
(paint) The opacity of the circle's stroke. |
circle_stroke_width |
(paint) The width of the circle's stroke.
Strokes are placed outside of the |
circle_translate |
(paint) The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. |
circle_translate_anchor |
(paint) Controls the frame of reference for |
visibility |
(layout) Whether the layer should be displayed. |
popup |
A mustache template in which the tags refer to the properties of the layer's data object. |
id |
The unique id of the layer. |
https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle
map <- as_mapbox_source(motor_vehicle_collisions_nyc) %>% mapboxer() %>% set_view_state(-73.9165, 40.7114, 11) %>% add_circle_layer( circle_color = "red", circle_radius = 5, popup = "{{date}} {{time}}" ) if (interactive()) map
map <- as_mapbox_source(motor_vehicle_collisions_nyc) %>% mapboxer() %>% set_view_state(-73.9165, 40.7114, 11) %>% add_circle_layer( circle_color = "red", circle_radius = 5, popup = "{{date}} {{time}}" ) if (interactive()) map
Add a standard control to the map
add_control(map, control_name, ..., pos = NULL) add_navigation_control(map, ..., pos = NULL) add_scale_control(map, ..., pos = NULL) add_fullscreen_control(map, pos = NULL)
add_control(map, control_name, ..., pos = NULL) add_navigation_control(map, ..., pos = NULL) add_scale_control(map, ..., pos = NULL) add_fullscreen_control(map, pos = NULL)
map |
A mapboxer object. |
control_name |
The (class) name of the control. |
... |
The options of the control. |
pos |
The position of the control. One of |
https://docs.mapbox.com/mapbox-gl-js/api/markers/ for available options for the used control.
map <- mapboxer() %>% add_navigation_control( pos = "top-left", showCompass = FALSE ) %>% add_fullscreen_control() %>% add_scale_control( unit = "nautical" ) if (interactive()) map
map <- mapboxer() %>% add_navigation_control( pos = "top-left", showCompass = FALSE ) %>% add_fullscreen_control() %>% add_scale_control( unit = "nautical" ) if (interactive()) map
Add a draw control to the map (experimental)
add_draw_control(map, ..., pos = NULL, data = NULL)
add_draw_control(map, ..., pos = NULL, data = NULL)
map |
A mapboxer object. |
... |
The options of the control. |
pos |
The position of the control. One of |
data |
A |
https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md for available options for the draw control.
Add a fill layer to the map
add_fill_layer(map, source = NULL, filter = NULL, fill_antialias = TRUE, fill_color = NULL, fill_opacity = NULL, fill_outline_color = NULL, fill_pattern = NULL, fill_sort_key = NULL, fill_translate = NULL, fill_translate_anchor = NULL, visibility = TRUE, popup = NULL, id = "fill-layer")
add_fill_layer(map, source = NULL, filter = NULL, fill_antialias = TRUE, fill_color = NULL, fill_opacity = NULL, fill_outline_color = NULL, fill_pattern = NULL, fill_sort_key = NULL, fill_translate = NULL, fill_translate_anchor = NULL, visibility = TRUE, popup = NULL, id = "fill-layer")
map |
A mapboxer object. |
source |
A Mapbox source. Uses the source from the mapboxer object if no source is supplied. |
filter |
A filter expression that is applied to the |
fill_antialias |
(paint) Whether or not the fill should be antialiased. |
fill_color |
(paint) The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used. |
fill_opacity |
(paint) The opacity of the entire fill layer.
In contrast to the |
fill_outline_color |
(paint) The outline color of the fill.
Matches the value of |
fill_pattern |
(paint) Name of image in sprite to use for drawing image fills. |
fill_sort_key |
(layout) Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. |
fill_translate |
(paint) The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. |
fill_translate_anchor |
(paint) Controls the frame of reference for |
visibility |
(layout) Whether the layer should be displayed. |
popup |
A mustache template in which the tags refer to the properties of the layer's data object. |
id |
The unique id of the layer. |
https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill
map <- as_mapbox_source(geojsonsf::geo_melbourne) %>% mapboxer() %>% set_view_state( lng = 144.9624, lat = -37.8105, zoom = 10, pitch = 35 ) %>% add_fill_layer( fill_color = c("get", "fillColor"), fill_opacity = 0.6, popup = "Area: {{AREASQKM}} km<sup>2</sup>", # AREASQKM > 5 filter = list(">", c("get", "AREASQKM"), 5) ) if (interactive()) map
map <- as_mapbox_source(geojsonsf::geo_melbourne) %>% mapboxer() %>% set_view_state( lng = 144.9624, lat = -37.8105, zoom = 10, pitch = 35 ) %>% add_fill_layer( fill_color = c("get", "fillColor"), fill_opacity = 0.6, popup = "Area: {{AREASQKM}} km<sup>2</sup>", # AREASQKM > 5 filter = list(">", c("get", "AREASQKM"), 5) ) if (interactive()) map
Add a filter control to the map
add_filter_control(map, layer_id, filter = NULL, pos = NULL, rows = 1, cols = 20)
add_filter_control(map, layer_id, filter = NULL, pos = NULL, rows = 1, cols = 20)
map |
A mapboxer object. |
layer_id |
The ID of the layer to which the filter is attached. |
filter |
The initial filter expression. |
pos |
The position of the control. One of |
rows |
The number of rows of the textarea input. |
cols |
The number of columns of the textarea input. |
Adds any kind of layer to the map.
The type of the layer is specified by the type
property of the
layer definintion.
add_layer(map, style, popup = NULL)
add_layer(map, style, popup = NULL)
map |
A mapboxer object. |
style |
A named list that defines the style of the layer. See https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/ for available style options for the used layer type. |
popup |
A mustache template in which the tags refer to the properties of the layer's data object. |
add_popups for an example of a mustache template used to generate the popup text.
image_src <- mapbox_source( type = "image", url = "https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif", coordinates = list( c(-80.425, 46.437), c(-71.516, 46.437), c(-71.516, 37.936), c(-80.425, 37.936) ) ) raster_style <- list( id = "overlay", type = "raster", source = image_src, paint = list( "raster-opacity" = 0.85 ) ) map <- mapboxer( center = c(-75.789, 41.874), zoom = 5 ) %>% add_layer(raster_style) if (interactive()) map
image_src <- mapbox_source( type = "image", url = "https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif", coordinates = list( c(-80.425, 46.437), c(-71.516, 46.437), c(-71.516, 37.936), c(-80.425, 37.936) ) ) raster_style <- list( id = "overlay", type = "raster", source = image_src, paint = list( "raster-opacity" = 0.85 ) ) map <- mapboxer( center = c(-75.789, 41.874), zoom = 5 ) %>% add_layer(raster_style) if (interactive()) map
Add a line layer to the map
add_line_layer(map, source = NULL, filter = NULL, line_blur = NULL, line_cap = NULL, line_color = NULL, line_dasharray = NULL, line_gap_width = NULL, line_gradient = NULL, line_join = NULL, line_miter_limit = NULL, line_offset = NULL, line_opacity = NULL, line_pattern = NULL, line_round_limit = NULL, line_sort_key = NULL, line_translate = NULL, line_translate_anchor = NULL, line_width = NULL, visibility = NULL, popup = NULL, id = "line-layer")
add_line_layer(map, source = NULL, filter = NULL, line_blur = NULL, line_cap = NULL, line_color = NULL, line_dasharray = NULL, line_gap_width = NULL, line_gradient = NULL, line_join = NULL, line_miter_limit = NULL, line_offset = NULL, line_opacity = NULL, line_pattern = NULL, line_round_limit = NULL, line_sort_key = NULL, line_translate = NULL, line_translate_anchor = NULL, line_width = NULL, visibility = NULL, popup = NULL, id = "line-layer")
map |
A mapboxer object. |
source |
A Mapbox source. Uses the source from the mapboxer object if no source is supplied. |
filter |
A filter expression that is applied to the |
line_blur |
(paint) Blur applied to the line, in pixels. |
line_cap |
(layout) The display of line endings. One of "butt", "round", "square". |
line_color |
(paint) The color with which the line will be drawn. |
line_dasharray |
(paint) Specifies the lengths of the alternating dashes and gaps that form the dash pattern. |
line_gap_width |
(paint) Draws a line casing outside of a line's actual path. The value indicates the width of the inner gap. |
line_gradient |
(paint) Defines a gradient with which to color a line feature.
Can only be used with GeoJSON sources that specify |
line_join |
(layout) The display of lines when joining. One of "bevel", "round", "miter". |
line_miter_limit |
(layout) Used to automatically convert miter joins to bevel joins for sharp angles.
Requires |
line_offset |
(paint) The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset. |
line_opacity |
(paint) The opacity at which the line will be drawn. |
line_pattern |
(paint) Name of image in sprite to use for drawing image lines. |
line_round_limit |
(layout) Used to automatically convert round joins to miter joins for shallow angles. |
line_sort_key |
(layout) Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. |
line_translate |
(paint) The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. |
line_translate_anchor |
(paint) Controls the frame of reference for |
line_width |
(paint) Stroke thickness. |
visibility |
(layout) Whether the layer should be displayed. |
popup |
A mustache template in which the tags refer to the properties of the layer's data object. |
id |
The unique id of the layer. |
https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line
map <- as_mapbox_source(geojsonsf::geo_melbourne) %>% mapboxer( center = c(144.9624, -37.8105), zoom = 11, pitch = 45 ) %>% add_navigation_control() %>% add_line_layer( line_color = c("get", "strokeColor"), line_width = 2, popup = "{{SA2_NAME}}" ) if (interactive()) map
map <- as_mapbox_source(geojsonsf::geo_melbourne) %>% mapboxer( center = c(144.9624, -37.8105), zoom = 11, pitch = 45 ) %>% add_navigation_control() %>% add_line_layer( line_color = c("get", "strokeColor"), line_width = 2, popup = "{{SA2_NAME}}" ) if (interactive()) map
Add a single marker to the map
add_marker(map, lng, lat, popup = NULL)
add_marker(map, lng, lat, popup = NULL)
map |
A mapboxer object. |
lng |
The longitude of the marker. |
lat |
The latitude of the marker. |
popup |
The popup text (HTML) that is displayed when you click on the marker. |
lng <- -0.09 lat <- 51.5 map <- mapboxer() %>% set_view_state(lng, lat) %>% add_marker(lng, lat, popup = "You are here!") if (interactive()) map
lng <- -0.09 lat <- 51.5 map <- mapboxer() %>% set_view_state(lng, lat) %>% add_marker(lng, lat, popup = "You are here!") if (interactive()) map
Add a mouse position control to the map
add_mouse_position_control(map, mustache_template = NULL, pos = NULL, css_text = NULL)
add_mouse_position_control(map, mustache_template = NULL, pos = NULL, css_text = NULL)
map |
A mapboxer object. |
mustache_template |
A mustache template
that contains the mustache tags |
pos |
The position of the control. One of |
css_text |
A |
map <- mapboxer(zoom = 4) %>% add_mouse_position_control( mustache_template = "<b>Lng:</b>{{lng}}, <b>Lat:</b>{{lat}}", pos = "bottom-left" ) if (interactive()) map
map <- mapboxer(zoom = 4) %>% add_mouse_position_control( mustache_template = "<b>Lng:</b>{{lng}}, <b>Lat:</b>{{lat}}", pos = "bottom-left" ) if (interactive()) map
Usually you will add the popups in the add_layer function by setting the popup
parameter.
add_popups(map, layer_id, popup)
add_popups(map, layer_id, popup)
map |
A mapboxer object. |
layer_id |
The ID of the layer to which you want to add the popups. |
popup |
A mustache template in which the tags refer to the properties of the layer's data object. |
LAYER_ID <- "crashes" mustache_tpl <- " <b>Date:</b> {{date}}</br> <b>Time:</b> {{time}}</br> <b>Number of persons injured:</b> {{injured}} " map <- motor_vehicle_collisions_nyc %>% as_mapbox_source() %>% mapboxer( center = c(-73.9165, 40.7114), zoom = 9 ) %>% add_circle_layer( circle_color = "red", circle_blur = 1, filter = list(">", "injured", 0), id = LAYER_ID ) %>% add_popups( LAYER_ID, popup = mustache_tpl ) if (interactive()) map
LAYER_ID <- "crashes" mustache_tpl <- " <b>Date:</b> {{date}}</br> <b>Time:</b> {{time}}</br> <b>Number of persons injured:</b> {{injured}} " map <- motor_vehicle_collisions_nyc %>% as_mapbox_source() %>% mapboxer( center = c(-73.9165, 40.7114), zoom = 9 ) %>% add_circle_layer( circle_color = "red", circle_blur = 1, filter = list(">", "injured", 0), id = LAYER_ID ) %>% add_popups( LAYER_ID, popup = mustache_tpl ) if (interactive()) map
Add a Mapbox source to the map
add_source(map, source, id = "mapboxer")
add_source(map, source, id = "mapboxer")
map |
A mapboxer object. |
source |
A Mapbox source. |
id |
The unique id of the data source. |
Add a text control to the map
add_text_control(map, text, pos = NULL, css_text = NULL)
add_text_control(map, text, pos = NULL, css_text = NULL)
map |
A mapboxer object. |
text |
The text (HTML) that is displayed. |
pos |
The position of the control. One of |
css_text |
A |
Add tooltips to a layer
add_tooltips(map, layer_id, tooltip)
add_tooltips(map, layer_id, tooltip)
map |
A mapboxer object. |
layer_id |
The ID of the layer to which you want to add the tooltips. |
tooltip |
A mustache template in which the tags refer to the properties of the layer's data object. |
Convert a data object to a Mapbox GeoJSON source
as_mapbox_source(data, ...) ## S3 method for class 'json' as_mapbox_source(data, ...) ## S3 method for class 'data.frame' as_mapbox_source(data, lng = "lng", lat = "lat", ...) ## S3 method for class 'sf' as_mapbox_source(data, ...)
as_mapbox_source(data, ...) ## S3 method for class 'json' as_mapbox_source(data, ...) ## S3 method for class 'data.frame' as_mapbox_source(data, lng = "lng", lat = "lat", ...) ## S3 method for class 'sf' as_mapbox_source(data, ...)
data |
A data frame that contains longitudes and latitudes in separate columns
or an |
... |
The properties of the source. See https://docs.mapbox.com/mapbox-gl-js/style-spec/sources for available options for the given source type. |
lng |
The name of the column containing the longitudes. |
lat |
The name of the column containing the latitudes. |
Creates a background style that can be used as basemap.
basemap_background_style(color = "#111", opacity = 1)
basemap_background_style(color = "#111", opacity = 1)
color |
The color of the background. |
opacity |
The opacity of the background. |
Creates a raster style that can be used as a basemap.
basemap_raster_style(tiles = stamen_raster_tiles("terrain"), attribution = NULL)
basemap_raster_style(tiles = stamen_raster_tiles("terrain"), attribution = NULL)
tiles |
A list of tile URLs. |
attribution |
The attribution text of the tile layer. |
A list of basemap style URLs
basemaps
basemaps
An object of class list
of length 2.
Fit the map to a bounding box
fit_bounds(map, bounds, ...)
fit_bounds(map, bounds, ...)
map |
A mapboxer object. |
bounds |
The bounding box as a vector in [west, south, east, north] order
or a |
... |
Optional arguments, see https://docs.mapbox.com/mapbox-gl-js/api/map/#map#fitbounds. |
Create a Mapbox source
mapbox_source(type, ...)
mapbox_source(type, ...)
type |
The type of the source, e. g. |
... |
The properties of the source. See https://docs.mapbox.com/mapbox-gl-js/style-spec/sources for available options for the given source type. |
Create a mapboxer widget
mapboxer(source = NULL, style = basemaps$Carto$dark_matter, ..., width = NULL, height = NULL, element_id = NULL, token = Sys.getenv("MAPBOX_API_TOKEN"))
mapboxer(source = NULL, style = basemaps$Carto$dark_matter, ..., width = NULL, height = NULL, element_id = NULL, token = Sys.getenv("MAPBOX_API_TOKEN"))
source |
A mapbox_source that is added to the map with the ID |
style |
The map's Mapbox style. |
... |
The properties of the map, see https://docs.mapbox.com/mapbox-gl-js/api/map/. |
width |
The width of the widget. |
height |
The height of the widget. |
element_id |
The unique ID of the widget. |
token |
A Mapbox API access token. Only needed if you want to use styles from Mapbox. |
map <- mapboxer( center = c(-73.9165, 40.7114), zoom = 10, minZoom = 6, pitch = 30, bearing = 45 ) if (interactive()) map
map <- mapboxer( center = c(-73.9165, 40.7114), zoom = 10, minZoom = 6, pitch = 30, bearing = 45 ) if (interactive()) map
Create a mapboxer
-like object that can be used to update a mapboxer object
that has already been rendered in a Shiny app.
mapboxer_proxy(shiny_id, session = shiny::getDefaultReactiveDomain())
mapboxer_proxy(shiny_id, session = shiny::getDefaultReactiveDomain())
shiny_id |
The output ID of the mapboxer object that should be updated. |
session |
The current Shiny session object. Usually the default value can be used. |
Output and render functions for using mapboxer within Shiny applications and interactive Rmd documents.
mapboxerOutput(outputId, width = "100%", height = "400px") renderMapboxer(expr, env = parent.frame(), quoted = FALSE)
mapboxerOutput(outputId, width = "100%", height = "400px") renderMapboxer(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a mapboxer |
env |
The environment in which to evaluate |
quoted |
Is |
library(shiny) library(mapboxer) LAYER_ID <- "mvc" view <- basicPage( h1("mapboxer"), sliderInput( "slider", "Number of persons injured", min = 0, max = max(motor_vehicle_collisions_nyc$injured), step = 1, value = 0 ), checkboxInput("hide", "Hide layer"), mapboxerOutput("map"), htmlOutput("datetime") ) server <- function(input, output) { output$map <- renderMapboxer({ as_mapbox_source(motor_vehicle_collisions_nyc) %>% mapboxer( center = c(-73.9165, 40.7114), zoom = 10, style = basemap_raster_style(stamen_raster_tiles()) ) %>% add_circle_layer( circle_color = "black", popup = "Number of persons injured {{injured}}", id = LAYER_ID ) %>% add_mouse_position_control( "Lng: {{lng}}</br>Lat: {{lat}}", css_text = "text-align: left; width: 180px;" ) %>% add_navigation_control(pos = "top-left") }) observeEvent(input$slider, { mapboxer_proxy("map") %>% set_filter(LAYER_ID, list("==", "injured", input$slider)) %>% update_mapboxer() }) observeEvent(input$hide, { mapboxer_proxy("map") %>% set_layout_property(LAYER_ID, "visibility", !input$hide) %>% update_mapboxer() }) output$datetime <- renderText({ props <- input$map_onclick$props sprintf("<p>%s %s</p>", props$date, props$time) }) } if (interactive()) shinyApp(view, server)
library(shiny) library(mapboxer) LAYER_ID <- "mvc" view <- basicPage( h1("mapboxer"), sliderInput( "slider", "Number of persons injured", min = 0, max = max(motor_vehicle_collisions_nyc$injured), step = 1, value = 0 ), checkboxInput("hide", "Hide layer"), mapboxerOutput("map"), htmlOutput("datetime") ) server <- function(input, output) { output$map <- renderMapboxer({ as_mapbox_source(motor_vehicle_collisions_nyc) %>% mapboxer( center = c(-73.9165, 40.7114), zoom = 10, style = basemap_raster_style(stamen_raster_tiles()) ) %>% add_circle_layer( circle_color = "black", popup = "Number of persons injured {{injured}}", id = LAYER_ID ) %>% add_mouse_position_control( "Lng: {{lng}}</br>Lat: {{lat}}", css_text = "text-align: left; width: 180px;" ) %>% add_navigation_control(pos = "top-left") }) observeEvent(input$slider, { mapboxer_proxy("map") %>% set_filter(LAYER_ID, list("==", "injured", input$slider)) %>% update_mapboxer() }) observeEvent(input$hide, { mapboxer_proxy("map") %>% set_layout_property(LAYER_ID, "visibility", !input$hide) %>% update_mapboxer() }) output$datetime <- renderText({ props <- input$map_onclick$props sprintf("<p>%s %s</p>", props$date, props$time) }) } if (interactive()) shinyApp(view, server)
Motor Vehicle Collisions in NYC
motor_vehicle_collisions_nyc
motor_vehicle_collisions_nyc
A data frame with 1601 rows and 6 variables, where each row is a Motor Vehicle Collision:
occurrence date of collision
occurrence time of collision
latitude coordinate for Global Coordinate System, WGS 1984, decimal degrees (EPSG 4326)
longitude coordinate for Global Coordinate System, WGS 1984, decimal degrees (EPSG 4326)
number of persons injured
number of persons killed
https://opendata.cityofnewyork.us/
Update the data of a Mapbox source
set_data(map, data, source_id = NULL, ...) ## S3 method for class 'character' set_data(map, data, source_id = NULL, ...) ## S3 method for class 'json' set_data(map, data, source_id = NULL, ...) ## S3 method for class 'data.frame' set_data(map, data, source_id = NULL, lng = "lng", lat = "lat", ...) ## S3 method for class 'sf' set_data(map, data, source_id, ...)
set_data(map, data, source_id = NULL, ...) ## S3 method for class 'character' set_data(map, data, source_id = NULL, ...) ## S3 method for class 'json' set_data(map, data, source_id = NULL, ...) ## S3 method for class 'data.frame' set_data(map, data, source_id = NULL, lng = "lng", lat = "lat", ...) ## S3 method for class 'sf' set_data(map, data, source_id, ...)
map |
A mapboxer_proxy object. |
data |
A |
source_id |
The ID of the source whose data should be updated. |
... |
unused |
lng |
The name of the column containing the longitudes. |
lat |
The name of the column containing the latitudes. |
Set the filter of a layer
set_filter(map, layer_id, filter)
set_filter(map, layer_id, filter)
map |
A mapboxer object. |
layer_id |
The ID of the layer whose property should be updated. |
filter |
A filter expression that is applied to the |
Update layer properties
set_paint_property(map, layer_id, property, value) set_layout_property(map, layer_id, property, value)
set_paint_property(map, layer_id, property, value) set_layout_property(map, layer_id, property, value)
map |
A mapboxer object. |
layer_id |
The ID of the layer whose property should be updated. |
property |
The name of the property that should be updated. |
value |
The new value of the property. |
set_paint_property
: Update a paint property of a layer.
set_layout_property
: Update a layout property of a layer.
Set the style of the map
set_style(map, style)
set_style(map, style)
map |
A mapboxer object. |
style |
The map's Mapbox style. |
Set the view state of the map
set_view_state(map, lng, lat, zoom = 9, pitch = 0, bearing = 0)
set_view_state(map, lng, lat, zoom = 9, pitch = 0, bearing = 0)
map |
A mapboxer object. |
lng |
The longitude of the geographical center point of the map. |
lat |
The latitude of the geographical center point of the map. |
zoom |
The zoom level of the map. |
pitch |
The pitch (tilt) of the map. |
bearing |
The bearing (rotation) of the map. |
Get Stamen raster tile URLs
stamen_raster_tiles(theme = c("watercolor"))
stamen_raster_tiles(theme = c("watercolor"))
theme |
The theme of the tiles. |
Update a mapboxer proxy object in a Shiny app
update_mapboxer(proxy_obj, ...)
update_mapboxer(proxy_obj, ...)
proxy_obj |
A |
... |
unused |