Open Makiavel974 opened 9 years ago
Yes, you may use different colors for the circles (or circle markers). Here is a minimal example using the new leaflet package (https://github.com/rstudio/leaflet):
library(leaflet)
df1 = data.frame(lat = rnorm(100), lng = rnorm(100))
df2 = data.frame(color = topo.colors(100, alpha = NULL), stringsAsFactors = FALSE)
leaflet(df1) %>% addCircleMarkers(color = df2$color)
hi, oh yes ! thanks you so much. i won't be at work during one week. But I'll try this as soon as possible. I'll give you a feedback. Thanks so much. regards
hi,
sorry another question. How to use df2 in a reactive object from shiny ? i.e : color_cities = reactive({df2)}
leaflet(df1) %>% addCircleMarkers(color = color_cities())
thanks so much.
I think you mean color_cities()$color
where color_cities()
is a reactive function that returnsdf2
?
Hi yihui,
I have tried to use this method to present different locations. I just wondering how to addlegend with colors. I saw several examples from other sites, they only can present the range data. Can we show the label with those color in this case? This means we can through the label to know the meaning of colors.
Thanks. Regards
Hi Jcheng5,
first, thank you for your active contributions.
I've adapted your code "Population" to my shiny application. It works very well. The circle width is based on a data frame (df_cases). But I would like to define color according a another data frame(df_alert), 0 no alert (green color) and 1 for alert (red color). Both data frame have same dimension and structure.
Thanks so much for your answer. regards.