问题
I developed a Shiny-app where I make use of the leaflet package to plot a large nr of point (~25.000) on a geographical background. When I start the app from R-studio it all works very well. On the same server I have a shiny-server running. I deployd several apps on this server without any problems. I deployd the app on the shiny-server to make it available for end-users.
The issue
On shiny-server it looks like the app has a problems handling the number of markers (~25.000). The app 'hangs', I can't do anything, but restart the app. With a smaller number of points (<10.000) there is no problem.
I couldn't find this problem anywhere else.
Any ideas on what the problem is and how to solve it?
Here is my code I used to test the problem
shinyServer(function(input, output) {
# Deel Interactive Map
plot_data <- reactive({
columns <- c("lng",
"lat",
"perc_gtv");
dt_installaties[1:input$nr_points,
columns,
with=FALSE];
})
output$map_branche <- renderLeaflet({
leaflet() %>%
setView(lng = 5.5,
lat = 52.5,
zoom = 8) %>%
addProviderTiles("OpenStreetMap.HOT")
})
# Observer that changes the markers as the nr of points is
# being changed
observe({
pal <- colorBin(palette = c("red","green"),
domain = c(0,200),
bins = 7)
leafletProxy("map_branche",
data = plot_data()) %>%
clearMarkers() %>%
addCircleMarkers(
lng = ~lng,
lat = ~lat,
color = ~pal(perc_gtv),
fillOpacity = 0.9)
})
})
shinyUI(
fluidPage(
fluidRow(
numericInput(
"nr_points",
label = h4("Points to plot"),
value = 5000,
min = 1,
max = nrow(dt_installaties)
)
),
mainPanel(
leafletOutput("map_branche")
)
)
)
My configuration
- platform: x86_64-redhat-linux-gnu
- R: 3.2.2 R-studio: 0.98.1103
- Leaflet: 1.0.0
- Shiny: 0.12.2
- Shiny-server: public/free version
来源:https://stackoverflow.com/questions/34607908/using-many-markers-with-leaflet-in-combination-with-shiny-server