From 2e37b2e41366e25ae1e73de11e0f176c0e713c24 Mon Sep 17 00:00:00 2001 From: Sebastian Gatscha Date: Wed, 16 Oct 2024 16:11:53 +0200 Subject: [PATCH] fix: fillColor argument for pulseIcons --- NEWS.md | 2 + R/pulseIcon.R | 7 +++- inst/examples/shiny/groupedlayercontrol_app.R | 2 +- man/addGroupedLayersControl.Rd | 38 +++++++++++-------- man/leaflet.extras-package.Rd | 2 +- man/pulseMarkers.Rd | 18 ++++++++- 6 files changed, 48 insertions(+), 21 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7375c04a..747d8273 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ - Include the plugin [`leaflet-groupedlayercontrol`](https://github.com/ismyrnow/leaflet-groupedlayercontrol). See the example in `/inst/examples/shiny/groupedlayercontrol_app.R` for a demo of all options and methods. Fix #202 +## Bugfixes +- New argument `fillColor` for `pulseIcons`. Fix #231 # leaflet.extras 2.0.1 diff --git a/R/pulseIcon.R b/R/pulseIcon.R index 0dabe446..ecce8817 100644 --- a/R/pulseIcon.R +++ b/R/pulseIcon.R @@ -76,11 +76,12 @@ pulseIconSetToPulseIcons <- function(x) { #' @rdname pulseMarkers makePulseIcon <- function( color = "#ff0000", + fillColor = color, iconSize = 12, animate = TRUE, heartbeat = 1) { icon <- leaflet::filterNULL(list( - color = color, iconSize = iconSize, animate = animate, heartbeat = heartbeat + color = color, fillColor = fillColor, iconSize = iconSize, animate = animate, heartbeat = heartbeat )) structure(icon, class = "leaflet_pulse_icon") } @@ -93,6 +94,7 @@ makePulseIcon <- function( #' icon data. Shorter argument values will be re-cycled. \code{NULL} values for #' these arguments will be ignored. #' @param color Color of the icon +#' @param fillColor Fill color of the icon #' @param iconSize Size of Icon in Pixels. #' @param animate To animate the icon or not, defaults to TRUE. #' @param heartbeat Interval between each pulse in seconds. @@ -100,11 +102,12 @@ makePulseIcon <- function( #' @rdname pulseMarkers pulseIcons <- function( color = "#ff0000", + fillColor = color, iconSize = 12, animate = TRUE, heartbeat = 1) { leaflet::filterNULL(list( - color = color, iconSize = iconSize, animate = animate, heartbeat = heartbeat + color = color, fillColor = fillColor, iconSize = iconSize, animate = animate, heartbeat = heartbeat )) } diff --git a/inst/examples/shiny/groupedlayercontrol_app.R b/inst/examples/shiny/groupedlayercontrol_app.R index 0d177d80..34ac5976 100644 --- a/inst/examples/shiny/groupedlayercontrol_app.R +++ b/inst/examples/shiny/groupedlayercontrol_app.R @@ -49,7 +49,7 @@ server <- function(input, output, session) { addCircleMarkers(runif(20, -75, -74), runif(20, 41, 42), color = "lightblue", group = "Markers4") %>% addCircleMarkers(runif(20, -75, -74), runif(20, 41, 42), color = "purple", group = "Markers5") %>% addGroupedLayersControl( - baseGroups = c("OpenStreetMap","CartoDB"), + baseGroups = c(list("Base1" = "OpenStreetMap")), overlayGroups = list("Layergroup_2" = c("Markers5","Markers4"), "Layergroup_1" = c("Markers2","Markers1","Markers3")), position = "topright", diff --git a/man/addGroupedLayersControl.Rd b/man/addGroupedLayersControl.Rd index 8fa4a7ce..5e6a8e8d 100644 --- a/man/addGroupedLayersControl.Rd +++ b/man/addGroupedLayersControl.Rd @@ -41,28 +41,36 @@ leaflet() \%>\% addTiles(group = "OpenStreetMap") \%>\% addProviderTiles("CartoDB", group = "CartoDB") \%>\% addCircleMarkers(runif(20, -75, -74), runif(20, 41, 42), - color = "red", group = "Markers2") \%>\% + color = "red", group = "Markers2" + ) \%>\% addCircleMarkers(runif(20, -75, -74), runif(20, 41, 42), - color="green", group = "Markers1") \%>\% + color = "green", group = "Markers1" + ) \%>\% addCircleMarkers(runif(20, -75, -74), runif(20, 41, 42), - color="yellow", group = "Markers3") \%>\% + color = "yellow", group = "Markers3" + ) \%>\% addCircleMarkers(runif(20, -75, -74), runif(20, 41, 42), - color = "lightblue", group = "Markers4") \%>\% + color = "lightblue", group = "Markers4" + ) \%>\% addCircleMarkers(runif(20, -75, -74), runif(20, 41, 42), - color = "purple", group = "Markers5") \%>\% + color = "purple", group = "Markers5" + ) \%>\% addGroupedLayersControl( - baseGroups = c("OpenStreetMap","CartoDB"), + baseGroups = c("OpenStreetMap", "CartoDB"), overlayGroups = list( - "Layergroup_2" = c("Markers5","Markers4"), - "Layergroup_1" = c("Markers2","Markers1","Markers3")), + "Layergroup_2" = c("Markers5", "Markers4"), + "Layergroup_1" = c("Markers2", "Markers1", "Markers3") + ), position = "topright", - options = groupedLayersControlOptions(groupCheckboxes = TRUE, - collapsed = FALSE, - groupsCollapsable = TRUE, - sortLayers = FALSE, - sortGroups = FALSE, - sortBaseLayers = FALSE, - exclusiveGroups = "Layergroup_1") + options = groupedLayersControlOptions( + groupCheckboxes = TRUE, + collapsed = FALSE, + groupsCollapsable = TRUE, + sortLayers = FALSE, + sortGroups = FALSE, + sortBaseLayers = FALSE, + exclusiveGroups = "Layergroup_1" + ) ) } \seealso{ diff --git a/man/leaflet.extras-package.Rd b/man/leaflet.extras-package.Rd index 8f587254..1b262435 100644 --- a/man/leaflet.extras-package.Rd +++ b/man/leaflet.extras-package.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/leaflet.extras-package.R +% Please edit documentation in R/leaflet.extras-package.r \docType{package} \name{leaflet.extras-package} \alias{leaflet.extras} diff --git a/man/pulseMarkers.Rd b/man/pulseMarkers.Rd index 1ad60eb5..d9a8df60 100644 --- a/man/pulseMarkers.Rd +++ b/man/pulseMarkers.Rd @@ -12,9 +12,21 @@ pulseIconList(...) \method{[}{leaflet_pulse_icon_set}(x, i) -makePulseIcon(color = "#ff0000", iconSize = 12, animate = TRUE, heartbeat = 1) +makePulseIcon( + color = "#ff0000", + fillColor = color, + iconSize = 12, + animate = TRUE, + heartbeat = 1 +) -pulseIcons(color = "#ff0000", iconSize = 12, animate = TRUE, heartbeat = 1) +pulseIcons( + color = "#ff0000", + fillColor = color, + iconSize = 12, + animate = TRUE, + heartbeat = 1 +) addPulseMarkers( map, @@ -42,6 +54,8 @@ addPulseMarkers( \item{color}{Color of the icon} +\item{fillColor}{Fill color of the icon} + \item{iconSize}{Size of Icon in Pixels.} \item{animate}{To animate the icon or not, defaults to TRUE.}