Skip to content

Commit

Permalink
adding ability to turn marker on and off
Browse files Browse the repository at this point in the history
  • Loading branch information
tomroh committed Oct 20, 2021
1 parent f001baf commit 56b14c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 13 additions & 4 deletions R/legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,10 @@ makeSizeIcons <- function(values,
#'
#' character string of style argument for HTML text
#'
#' @param marker
#'
#' whether to show the marker or only the icon
#'
#' @param orientation
#'
#' stack the legend items vertically or horizontally
Expand Down Expand Up @@ -1337,6 +1341,7 @@ makeSizeIcons <- function(values,
#' labelStyle = 'font-size: 16px;') |>
#' addLegendAwesomeIcon(iconSet = iconSet,
#' orientation = 'vertical',
#' marker = FALSE,
#' title = htmltools::tags$div(
#' style = 'font-size: 20px;',
#' 'Awesome Icons'),
Expand All @@ -1346,6 +1351,7 @@ addLegendAwesomeIcon <- function(map,
title = NULL,
labelStyle = '',
orientation = c('vertical', 'horizontal'),
marker = TRUE,
group = NULL,
className = 'info legend leaflet-control',
...) {
Expand All @@ -1361,13 +1367,16 @@ addLegendAwesomeIcon <- function(map,
Map(icon = iconSet,
label = names(iconSet),
f = function(icon, label) {
markerClass <- ''
if ( marker ) {
markerClass <- sprintf('awesome-marker-icon-%s awesome-marker %s',
icon[['markerColor']],
ifelse(icon[['squareMarker']], 'awesome-marker-square', ''))
}
htmltools::tagList(
wrapElements(
htmltools::tags$div(style = 'vertical-align: middle; display: inline-block; position: relative;',
class =
sprintf('awesome-marker-icon-%s awesome-marker %s',
icon[['markerColor']],
ifelse(icon[['squareMarker']], 'awesome-marker-square', '')),
class = markerClass,
htmltools::tags$i(class = sprintf('%1$s %1$s-%2$s %3$s',
icon[['library']],
icon[['icon']],
Expand Down
4 changes: 4 additions & 0 deletions man/addLegendAwesomeIcon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 56b14c7

Please sign in to comment.