I'm using ShinyProxy to deploy R ShinyApps.
I plot on a Leaflet Map marker point and cluster them because I have more than one (actually a lot) points for the same coordinates.
Each point can be in two state, so I change the color in Red or Green.
I'd like to change the color of the "cluster marker" too in:
- red if at least one marker inside of it is red
- green otherwise
Here a (simple dummy) photo to better explain what I mean:
I searched a lot but I cannot find a solution to my problem.
Here a portion of my code:
getColor <- function(dfMap) {
dati = lapply(dfMap$Id, function(x){ if(x %in% alarm$id){return("red")}else{ return("green")}})
return(unlist(dati))
}
icons <- awesomeIcons(
icon = 'ios-close',
iconColor = 'black',
library = 'ion',
markerColor = getColor(dfMap)
)
map = leaflet(dfMap,options = leafletOptions(worldCopyJump = T)) %>% addTiles() %>%
addAwesomeMarkers(as.numeric(dfMap$lon), as.numeric(dfMap$lat), icon=icons, label=~as.character(dfMap$Id), clusterOptions = markerClusterOptions())
output$alarmMap = renderLeaflet(map)
The data are a DataFrame with:
- lat / long
- element id
I have also another DataFrame that contains only element that should be red.
Thanks a lot for any help.