map: A map object created by the mapboxgl or maplibre functions.
id: A unique ID for the layer.
source: The ID of the source, alternatively an sf object (which will be converted to a GeoJSON source) or a named list that specifies type and url for a remote source.
source_layer: The source layer (for vector sources).
icon_allow_overlap: If TRUE, the icon will be visible even if it collides with other previously drawn symbols.
icon_anchor: Part of the icon placed closest to the anchor.
icon_color_brightness_max: The maximum brightness of the icon color.
icon_color_brightness_min: The minimum brightness of the icon color.
icon_color_contrast: The contrast of the icon color.
icon_color_saturation: The saturation of the icon color.
icon_emissive_strength: The strength of the icon's emissive color.
icon_halo_blur: The blur applied to the icon's halo.
icon_halo_color: The color of the icon's halo.
icon_halo_width: The width of the icon's halo.
icon_ignore_placement: If TRUE, the icon will be visible even if it collides with other symbols.
icon_image: Name of image in sprite to use for drawing an image background. To use values in a column of your input dataset, use get_column('YOUR_ICON_COLUMN_NAME'). Images can also be loaded with the add_image() function which should precede the add_symbol_layer() function.
icon_image_cross_fade: The cross-fade parameter for the icon image.
icon_keep_upright: If TRUE, the icon will be kept upright.
icon_offset: Offset distance of icon.
icon_opacity: The opacity at which the icon will be drawn.
icon_optional: If TRUE, the icon will be optional.
icon_padding: Padding around the icon.
icon_pitch_alignment: Alignment of the icon with respect to the pitch of the map.
icon_rotate: Rotates the icon clockwise.
icon_rotation_alignment: Alignment of the icon with respect to the map.
icon_size: The size of the icon, specified relative to the original size of the image. For example, a value of 5 would make the icon 5 times larger than the original size, whereas a value of 0.5 would make the icon half the size of the original.
icon_text_fit: Scales the text to fit the icon.
icon_text_fit_padding: Padding for text fitting the icon.
icon_translate: The offset distance of the icon.
icon_translate_anchor: Controls the frame of reference for icon-translate.
symbol_avoid_edges: If TRUE, the symbol will be avoided when near the edges.
symbol_placement: Placement of the symbol on the map.
symbol_sort_key: Sorts features in ascending order based on this value.
symbol_spacing: Spacing between symbols.
symbol_z_elevate: If TRUE, positions the symbol on top of a fill-extrusion layer. Requires symbol_placement to be set to "point" and symbol-z-order to be set to "auto".
symbol_z_offset: The elevation of the symbol, in meters. Use get_column() to get elevations from a column in the dataset.
symbol_z_order: Orders the symbol z-axis.
text_allow_overlap: If TRUE, the text will be visible even if it collides with other previously drawn symbols.
text_anchor: Part of the text placed closest to the anchor.
text_color: The color of the text.
text_emissive_strength: The strength of the text's emissive color.
text_field: Value to use for a text label.
text_font: Font stack to use for displaying text.
text_halo_blur: The blur applied to the text's halo.
text_halo_color: The color of the text's halo.
text_halo_width: The width of the text's halo.
text_ignore_placement: If TRUE, the text will be visible even if it collides with other symbols.
text_justify: The justification of the text.
text_keep_upright: If TRUE, the text will be kept upright.
text_letter_spacing: Spacing between text letters.
text_line_height: Height of the text lines.
text_max_angle: Maximum angle of the text.
text_max_width: Maximum width of the text.
text_offset: Offset distance of text.
text_opacity: The opacity at which the text will be drawn.
text_optional: If TRUE, the text will be optional.
text_padding: Padding around the text.
text_pitch_alignment: Alignment of the text with respect to the pitch of the map.
text_radial_offset: Radial offset of the text.
text_rotate: Rotates the text clockwise.
text_rotation_alignment: Alignment of the text with respect to the map.
text_size: The size of the text.
text_transform: Transform applied to the text.
text_translate: The offset distance of the text.
text_translate_anchor: Controls the frame of reference for text-translate.
text_variable_anchor: Variable anchor for the text.
text_writing_mode: Writing mode for the text.
visibility: Whether this layer is displayed.
slot: An optional slot for layer order.
min_zoom: The minimum zoom level for the layer.
max_zoom: The maximum zoom level for the layer.
popup: A column name containing information to display in a popup on click. Columns containing HTML will be parsed.
tooltip: A column name containing information to display in a tooltip on hover. Columns containing HTML will be parsed.
hover_options: A named list of options for highlighting features in the layer on hover. Not all elements of SVG icons can be styled.
before_id: The name of the layer that this layer appears "before", allowing you to insert layers below other layers in your basemap (e.g. labels).
filter: An optional filter expression to subset features in the layer.
cluster_options: A list of options for clustering symbols, created by the cluster_options() function.
Returns
The modified map object with the new symbol layer added.
Examples
## Not run:library(mapgl)library(sf)library(dplyr)# Set seed for reproducibilityset.seed(1234)# Define the bounding box for Washington DC (approximately)bbox <- st_bbox( c( xmin =-77.119759, ymin =38.791645, xmax =-76.909393, ymax =38.995548), crs = st_crs(4326))# Generate 30 random points within the bounding boxrandom_points <- st_as_sf( data.frame( id =1:30, lon = runif(30, bbox["xmin"], bbox["xmax"]), lat = runif(30, bbox["ymin"], bbox["ymax"])), coords = c("lon","lat"), crs =4326)# Assign random iconsicons <- c("music","bar","theatre","bicycle")random_points <- random_points |> mutate(icon = sample(icons, n(), replace =TRUE))# Map with iconsmapboxgl(style = mapbox_style("light"))|> fit_bounds(random_points, animate =FALSE)|> add_symbol_layer( id ="points-of-interest", source = random_points, icon_image = c("get","icon"), icon_allow_overlap =TRUE, tooltip ="icon")## End(Not run)