Skip to content

Commit

Permalink
Merge pull request #798 from npct/line-redraw
Browse files Browse the repository at this point in the history
Fix lines are again redrawn
  • Loading branch information
nikolai-b authored Sep 18, 2019
2 parents 12533fb + af9c840 commit da04a1f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions regions_www/m/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ shinyServer(function(input, output, session) {
##############

## Create region and (for persistent geographical values) helper
region <- reactiveValues(current = NA, data_dir = NA, geography = NA, repopulate_region = F, purposes_present = NA, plot = NULL, line_data_dir = "")
region <- reactiveValues(current = NA, data_dir = NA, geography = NA, repopulate_region = F, purposes_present = NA, plot = NULL, line_data_dir = "", ldata = NULL)
helper <- NULL
helper$e_lat_lng <- ""
helper$old_geog <- ""
Expand Down Expand Up @@ -574,6 +574,12 @@ shinyServer(function(input, output, session) {
input$scenario
input$line_order

# If we are showing lines and the input is not frozen then we want to trigger this observe
# when the map bounds change
if (!isTruthy(input$line_type %in% show_no_lines) && !isTRUE(input$freeze)){
input$map_bounds
}

isolate({
shinyjs::showElement(id = "loading")

Expand All @@ -596,18 +602,18 @@ shinyServer(function(input, output, session) {
local_lines <- local_lines[local_lines$dutch_slc>0,] # always >0 for both
}
}
if (is.null(region$plot$ldata) || (!is.null(region$plot$ldata) && (!identical(region$plot$ldata, local_lines) || !identical(region$plot$scenario, input$scenario)))) {
if (is.null(region$ldata) || (!is.null(region$ldata) && (!identical(region$ldata, local_lines) || !identical(region$plot$scenario, input$scenario)))) {
leafletProxy("map") %>% clearGroup(.,
c("straight_lines",
"routes_quieter",
"routes_fast",
"route_network"
)) %>%
removeShape(., "highlighted")
region$plot$ldata <- local_lines
region$ldata <- local_lines
# Include current scenario in region$plot as the set of lines to plot may not change when the scenario alters, and so otherwise don't update
region$plot$scenario <- input$scenario
plot_lines(leafletProxy("map"), region$plot$ldata, line_type)
plot_lines(leafletProxy("map"), region$ldata, line_type)
# Additionally plot fast routes on top of quieter if selected 'fast & quieter'
if (input$line_type == 'routes') {
plot_lines(leafletProxy("map"), sort_lines(region$plot$routes_fast, "routes_fast", input$nos_lines),"routes_fast")
Expand Down

0 comments on commit da04a1f

Please sign in to comment.