mapdeck
mapdeck copied to clipboard
add_polygons not panning as intended witihin a shiny app
Describe the bug When using mapdeck in a shinyapp, the ability to pan across the screen for add_polygon does not appear to work when the little hand is on a polygon (i.e. left click the mouse to drag the screen around). However, you can pan when the hand is on the background map. This behavious does not happen when using mapdeck on its own.
To Reproduce
library(mapdeck)
library(sf)
library(spData)
ui <- fluidPage(
# Main panel for displaying outputs ----
mainPanel(
# Output: Histogram ----
mapdeckOutput(outputId = "map", height = 900)
)
)
server <- function(input, output) {
## Currently supports sf objects projected into Web Mercartor
sf <- sf::st_sf(nz)
sf <- sf::st_transform(sf, "+init=epsg:4326")
## you need a MAPBOX access token
# key <- read.dcf("~/Documents/.googleAPI", fields = "MAPBOX")
observe({
output$map <- renderMapdeck({
mapdeck(min_zoom = 5,
# token = key
style = 'mapbox://styles/mapbox/dark-v9'
) %>%
add_polygon(
data = sf
, layer_id = "polygon"
, fill_colour = "Median_income"
)
})
})
}
shinyApp(ui, server)
system details
R version 4.0.4 (2021-02-15) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] spData_0.3.10 shinydashboard_0.7.2 sf_1.0-7 dplyr_1.0.8
[5] RSQLite_2.2.7 magrittr_2.0.3 mapdeck_0.3.40003 shiny_1.7.1
[9] ee.shinyapp2022_0.0.0.9000
I don't see the issue you're describing. Here's a screen recording of me dragging the polygons in a shiny
https://user-images.githubusercontent.com/8093396/168498661-98d65a46-817a-46b8-9322-686ae736b4f2.mov
I'm using the CRAN version - 0.3.4 - in this exmaple
Hey,
Did some testing and found that for the shiny package versoin 1.5.0 the app works as intended, however for shiny versions 1.6.0 and 1.7.0 the behaviour described above happens. Regards, P.
Tested again on shiny 1.8.0 and I'm not seeing this error. Please reopen if it persists.