rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
887 stars 299 forks source link

Unable to render map with Condition and updateselectinput in r #285

Open RadhaSwathi opened 5 years ago

RadhaSwathi commented 5 years ago

if (interactive()) { ui <- fluidPage(theme = "bootstrap.css",

bar layout with a input and output definitions ----

useShinyjs(),
sidebarLayout(

  # Sidebar panel for inputs ----
  sidebarPanel(
# Input: Selector for choosing dataset ----
    selectInput(inputId = "Method",
                label = 'Construction type:',
                choices = c("a", "b","c","d","e")),
    # Input: Selector for choosing dataset ----
    selectInput(inputId = "Z",
                label =''ne:',
                choices = c("Z2", "Z3")),
    conditionalPanel(
      condition= "input.Method=='a'",
    textInput( inputId="Height", label ="Height", placeholder = "Height")),
    conditionalPanel(
      condition= "input.Method!='c'",
    sliderInput(inputId = "c1",
                label = "c1",
                min = 0,
                max = 10000,
                value = 1)),
    actionButton("run", "Run Analysis", icon("paper-plane"), 
                 style="color: #fff; background-color: #337ab7; border-color: #2e6da4")

  ),

  # Main panel for displaying outputs ----
  mainPanel(
    # Output: Verbatim text for data summary ----
    verbatimTextOutput("summary"),
    google_mapOutput(outputId ="map1")

  )
)

)

In serever

output$map1 <- renderGoogle_map({ print("rendering") india= google_geocode('india',key=key) india= geocode_coordinates(india) coord=cbind(india$lat,india$lng) if(input$Method=="ESR") df<-read_excel("/U", sheet = "E") if (input$Method=="WTP") df<-read_excel("/Use, sheet = "r") if (input$Method=="CWR") df<-read_excel("/Ut = "t") if (input$Method=="CWPH") df<-read_excel("/Uxlsx", sheet = "o") if (input$Method=="Intake") df<-read_excel("/a.xlsx", sheet = "Ie") df_coords=as.data.frame(cbind(df$Lat,df$Lon)) print(df_coords) map= google_map(location = coord,data =df_coords, zoom = 4, key=key)%>% clear_markers() %>% add_markers(data = df_coords,lat = "V1", lon = "V2")

observe({ print("hiiii") updateSelectInput(session,"Method",selected = input$Method)

})