update_arcs: Dynamically update arcs

Description Usage Arguments Examples

View source: R/proxies.R

Description

Dynamically update arcs with Shiny.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
update_arcs(
  proxy,
  origin.lon,
  origin.lat,
  destination.lon,
  destination.lat,
  ...
)

update_arcs_name(proxy, origin, destination, ...)

Arguments

proxy

a proxy as returned by datamapsProxy.

origin.lon

origin coordinates.

origin.lat

origin coordinates.

destination.lon

destination coordinates.

destination.lat

destination coordinates.

...

any other arguments to use as options.

origin

edges.

destination

edges.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## Not run: 
library(shiny)

ui <- fluidPage(

  textInput(
    "from",
    "Origin",
    value = "USA"
  ),
  textInput(
    "to",
    "Destination",
    value = "RUS"
  ),
  actionButton(
    "submit",
    "Draw arc"
  ),
  datamapsOutput("map")
)

server <- function(input, output){

  arc <- reactive({
    data.frame(from = input$from, to = input$to)
  })

 output$map <- renderDatamaps({
   datamaps()
 })

 observeEvent(input$submit, {
   datamapsProxy("map") %>%
     add_data(arc()) %>%
     update_arcs_name(from, to)
 })

}

shinyApp(ui, server)

## End(Not run)

JohnCoene/datamaps documentation built on Aug. 30, 2020, 7:20 a.m.