Skip to content

deck gl layers toggle #198

@paragemini

Description

@paragemini

Hello -

I have a dataframe with racial makeup for Chicago. I am trying to add 5 different layers for 5 different races. Is there a way to toggle them on and off like one do in leaflet like the jpeg below ?

image

properties <- list(
  getPosition = ~lng + lat, #[165, 42,42]
  getRadius = 25, #JS("data => Math.sqrt(data.exits)"),
  #orange 246, 107, 14 
  # white race : blue dark : [64, 223, 239]
  #black race dark [255,198,0]  , light : 246, 107, 14
  getColor = JS("data => data.Type === 'White_alone' ? [10, 161, 221]: 
                data.Type === 'Black_or_African_American_alone' ? [246, 107, 14] : 
                data.Type === 'Some_other_race_alone' ? [6,255,0]: 
                data.Type === 'Asian_alone' ? [249, 7, 22] :
                data.Type === 'Two_or_more_races' ? [246, 107, 14] :
                data.Type === 'American_Indian_and_Alaska_Native_alone' ? [255, 23, 0] :
                data.Type === 'Native_Hawaiian_and_Other_Pacific_Islander_alone' ? [147, 255, 216] : [24, 10, 10]"),
  tooltip = "{{Type}}"
)

deck <- deckgl(zoom = 10.5, latitude = 41.889673, longitude = -87.634711) %>%
  add_scatterplot_layer(data = split_race_dot[[7]], properties = properties) %>%
  add_scatterplot_layer(data = split_race_dot[[3]], properties = properties, 
                        visible = FALSE) %>%
  add_scatterplot_layer(data = split_race_dot[[1]], properties = properties, 
                        visible = FALSE) %>%
  add_scatterplot_layer(data = split_race_dot[[2]], properties = properties, 
                        visible = FALSE) %>%
  add_scatterplot_layer(data = split_race_dot[[4]], properties = properties, 
                        visible = FALSE) %>%

  add_basemap(style = use_carto_style("positron"))  

if (interactive()) deck

Final layer box that could probably come at the top-right corner of the final map
Thank you for the lovely package!!

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions