Progress Bar for leaflet ?

485 views
Skip to first unread message

Samantha Sifleet

unread,
Jan 29, 2016, 4:04:37 PM1/29/16
to Shiny - Web Framework for R
Hi,

I'm working on an app that needs to load in a bigger shapefile to render in a leaflet map.

I've tried to add a progress bar to the renderLeaflet function like so:

output$map<-renderLeaflet({
     withProgress(message = 'Loading Map Data',
                  detail = 'Please be patient this may take a while...', value = 0, {
                    for (i in 1:60) {
                     incProgress(1/60)
                      Sys.sleep(0.25)
                    }
                  })
    leaflet() %>%
    setView(lng = -93.85, lat = 37.45, zoom = 4)%>%
    addGeoJSON(states, group = "state count")%>%
    addPolygons(data = county_data, stroke = F, fillOpacity = 0.5, #smoothfactor = 0.5, 
                 group = "county count",
                 color = ~colorQuantile("Greens", county_data$Count)(Count))%>%
    addPolygons(data = county_data, stroke = F, fillOpacity = 1, #smoothfactor = 0.5, 
                group = "county heat",
                color = ~colorQuantile("YlOrRd", county_data$A298th)(A298th))
   })

The problem is that the progress bar works finishes and then the map renders. So with the progress bar the map takes MUCH longer to render upwards of 20 seconds. (i.e. progress bar runs for about 15 seconds) then disappears and it's another 10 seconds before the map appears.  Without the progress bar sometimes the map will render in 8 seconds.  I think 8 seconds is too long for the user to wait.  Any ideas what's going on here?

Thanks,

Sam

Dan Oshea

unread,
May 19, 2016, 4:17:00 PM5/19/16
to Shiny - Web Framework for R
Just wandering if you ever found a solution.  Having same issue.

David Hodge

unread,
Oct 19, 2016, 8:16:34 PM10/19/16
to Shiny - Web Framework for R
Hi,
I'm having the same issue too. I don't suppose you managed to work out a solution to this?
Thanks,
Dave

Akbar bakhshi

unread,
Feb 6, 2019, 3:46:01 PM2/6/19
to Shiny - Web Framework for R
Hello,
I'm facing thee same problem. Has anyone found a solution?

Thank you,

-Akbar
Reply all
Reply to author
Forward
0 new messages