without seeing the rest of your code, my guess is that your data.frame converts the color strings into factors. When Shiny passes the parameters onto the Leaflet library, this finds no valid colors and uses the default black value. To supress this behaviour you could use stringsAsFactors = FALSE when constructing your data.frame.
Below is a reproducible example. Not the prettiest R code, but might be useful to someone.
library(shiny)
library(leaflet)
library(RColorBrewer)
library(plyr)
runApp(
list(
server=function(input, output, session) {
# create the map
map <- createLeafletMap(session, 'map')
# create some points
DF <- data.frame(
lat = c(52.4912694, 49.04323, 49.04323),
lon = c(13.292079, 13.49518, 8.39053),
id = c("A","B","C"),
myVar = runif(3,100,400),
color = c(brewer.pal(3,"Set3")) ,
stringsAsFactors = FALSE)
radiusFactor <- 10000
observe({
if(input$drawPoints == 0) {
return(NULL)
} else {
map$clearShapes()
# get data into a nested list with the dlply function.
paramList <- dlply(DF, 2, function(x) {
list(x[['lat']],
x[['lon']],
x[['myVar']]*radiusFactor/ max(12, input$map_zoom)^2,
x[['id']],
list(weight = 1.2, # stroke weight
fill = T, # fill object
color = '#808080', # stroke color, grey
opacity = 0.9, # stroke opacity
fillColor = x[['color']], # fill color
fillOpacity = 0.7, # fill opacity
clickable = T)
)})
# call lapply with custom wrapper function to map$addCircle.
# the names of the list have to be stripped before being sent to map$addCircle
lapply(paramList, function(x) do.call(map$addCircle, unname(x)))
}
})
},
ui=basicPage(
mainPanel(
options = list(center = c(51.01, 8.68), zoom = 6, maxZoom = 10, minZoom=4, maxBounds = list(list(30,-20),list(68,90)))),
actionButton("drawPoints", "Draw"))
))
)