Closed mpadge closed 4 years ago
It reacts when you change city. But should also react when you change scenario and mode of transport. You up for giving that a bash?
This all works, except that the map still resets each time the layer is changed, which is quite visually offputting. It nevertheless seems to be a mapdeck
or deck.gl
issue, I can almost get it to work, but the new add_path
initially appears over the default coordinates, and you have to do something to the map to get it to jump into place:
That definitely should not happen, so happy to close this for now and wait for an external resolution of that issue.
Ping @symbolixAU - just an FYI, but check that above image where those lines should be directly over Accra, and jump there as soon as the map is moved, but they initially revert to the default coordinates. You can reproduce that by cloning this repo, and passing an update_view
parameter to the plot_layer
function, appending it to the add_path
call. Then set update_view = TRUE
in the input$city
event, and update_view = FALSE
in the input$layer
event. Any help would be greatly appreciated, if you happened to have any quick insights.
Other than building the package, what else do I need to run the app? I keep getting
0 files found
when changing location.
oh yeah shit, sorry - ping @Robinlovelace what or where is the script to grab the other files?
Hey @SymbolixAU thanks for the input, this should do it (heads-up @mpadge I've put the data used by upthat in a new release in this repo, making it a more self-contained project):
devtools::install_github("atfutures/upthat", ref = "dl-function")
piggyback::pb_download(repo = "atfutures/upthat")
upthat::runUpthat()
but check that above image
I can't reproduce this image using
observeEvent({input$city}, {
matching_file = rds_files_available[grepl(pattern = input$city, x = rds_files_available, ignore.case = TRUE)]
if (length(matching_file) > 1){
message(length(matching_file), " files found, selecting the first")
matching_file = matching_file[1]
}
if (length(matching_file) < 1){
matching_file = system.file("net-kathmandu.Rds", package = "upthat")
}
message("Reading this matching file: ", matching_file)
net <<- readRDS(matching_file)
net$layer = net$flow
plot_layer (net, TRUE)
})
observeEvent({input$layer}, {
if (input$layer == "pedestrian flow") {
net$layer = net$flow
} else if (input$layer == "exposure") {
if ("exposure" %in% names (net))
net$layer = net$exposure
else
net$layer = net$flow
}
plot_layer (net, FALSE)
})
}
plot_layer = function (net, update_view) {
net$width = 20 * net$layer / max (net$layer, na.rm = TRUE)
mapdeck::mapdeck_update(map_id = "mymap") %>%
mapdeck::add_path(palette = "inferno", # see colourvalues::color_palettes()
net,
stroke_colour = "layer",
stroke_width = "width",
stroke_opacity = "layer",
legend = TRUE,
update_view = update_view,
layer_id = "mylayer")
But what I do see is the map initially zooming on Accra (responding to input$city
), then zooming out again (responding to input$layer
), which it shouldn't do.
Thanks Dave - I'll try to reproduce in a self-contained repo and ping you from there if problem persists
@SymbolixAU Good news: I can no longer reproduce the above problem with latest mapdeck
. Phew! Everything now functions perfectly for us. This tool is already running in very rough prototype form at atfutures.github.io/uta, and the WHO will hopefully move towards more permanent hosting in the near future (once we've got all the background data mechanics in stable form). So just in case you want some nice use-cases for your work, you'll soon be able to claim your code is used in WHO tools. Thanks for the great work!
Awesome. Keen to see the full version once it's up!
And I do like it when a bug just resolves itself...
It's currently not, so it's not possible to simply switch between viz layers based on user interactions. Easy to fix by switching current static app serving to
shinyReactive
form