0

Here in Leaflet there are function to do layer grouping layer like this https://rstudio.github.io/leaflet/showhide.html

It helps user to navigate between layer maps want to use such as grid, hex, heatmap, point cluster, etc.

I'm quite new user with shiny and mapdeck, and still can't figure it out how to make group layer.

How do we create it in Mapdeck and Shiny, here is code examples:

library(shiny)
library(shinydashboard)
library(mapdeck)


key <- 'MAPBOX_KEY'
nyc_airbnb <- read.csv("https://raw.githubusercontent.com/mahardisetyoso/shiny_hardysetyoso/main/shiny_dashboard/data/AB_NYC_2019.csv", stringsAsFactors = TRUE)

ui <- navbarPage("Shiny Dashboard",
                 tabPanel("Mapdeck",
                          mapdeckOutput("mapdeck", height = 1000, width = 1900)),
                 tabPanel("About")

)

server <- function(input, output) {
    output$mapdeck <- renderMapdeck({

        mapdeck(
            token = key,
            width = 700,
            height = 700,
            style = "mapbox://styles/mapbox/streets-v11",
            pitch = 50,
            bearing = 25,
            zoom = 10,
            location = c(-73.99701041459296,40.716870845525336)) %>%
            add_grid(
                data = nyc_airbnb,
                lat = "latitude",
                lon = "longitude",
                cell_size = 200,
                elevation_scale = 5,
                layer_id = "nyc_grid",
                update_view = FALSE
            )
    })


}

shinyApp(ui, server)

another MapDeck Viz i want to add as group layer

mapdeck(
      token = key,
      width = 700,
      height = 700,
      style = "mapbox://styles/mapbox/streets-v11",
      pitch = 50,
      bearing = 25,
      zoom = 10,
      location =c(-73.99701041459296,40.716870845525336)) %>%
  add_hexagon(
    data = nyc_airbnb,
    lat = "latitude",
    lon = "longitude",
    radius = 200,
    elevation_scale = 5,
    layer_id = "nyc_hex",
    update_view = FALSE
  )
  



  • There is no equivalent `addLayersControl()` for mapdeck. You have to create a seprate UI element, such as radio buttons or checkboxgroup, and observe the changes. [Here's a short article I wrote on the topic](https://symbolixau.github.io/mapdeck/articles/tips_tricks.html#updating-the-map) – SymbolixAU Jun 05 '21 at 09:47
  • Noted, let me check it – Mahardi Setyoso Jun 06 '21 at 04:00

0 Answers0