Using googleway R package with Shiny and updating the map with google_map_update and update_heatmap.
Is it possible to maintain the same zoom level and position during calls to google_map_update - it currently zooms out and pans around automatically when points change coordinates which is a headache - can this be turned off?
Code below is from the link, with automation turned on for the slider. Zoom in to the map and then animate and you'll see the auto zoom and panning occur.
library(shiny)
library(googleway)
ui <- fluidPage(
sliderInput(inputId = "sample", label = "sample", min = 1, max = 10,
step = 1, value = 10, animate = TRUE),
google_mapOutput(outputId = "map")
)
server <- function(input, output){
map_key <- ''
set.seed(20170417)
df <- tram_route[sample(1:nrow(tram_route), size = 10 * 100, replace = T), ]
output$map <- renderGoogle_map({
google_map(key = map_key) %>%
add_heatmap(data = df, lat = "shape_pt_lat", lon = "shape_pt_lon",
option_radius = 0.001)
})
observeEvent(input$sample,{
df <- tram_route[sample(1:nrow(tram_route), size = input$sample * 100, replace = T), ]
google_map_update(map_id = "map") %>%
update_heatmap(data = df, lat = "shape_pt_lat", lon = "shape_pt_lon")
})
}
shinyApp(ui, server)