为什么这个闪亮的应用程序无法正常工作?

时间:2019-04-17 19:17:18

标签: r

    library(leaflet)
    ui = fluidPage(

      TitlePannel
      titlePanel("Project Test"),

      SideBarLayout being used.
      sidebarLayout(
        #sidebar contains
        sidebarPanel(
                      textInput('log','EnterLongitude'), 
                      textInput(inputId = 'lati', label = 'EnterLatitude'),
                      actionButton("submit", "Submit")
                    ),# end of the sidebarPanel 

        #display contains                        
        mainPanel(renderLeaflet("info"))  #end of the mainPanel 
#i believe there might be some mistake in mainPanel
                   ) #end of the sidebar layout
          )# end of the fluid page layout

    #Start of the control function
    server = function(session, input, output){
       observeEvent(input$submit, {
        log <- as.numeric(input$log)
        lati <- as.numeric(input$lati)
        m = leaflet() %>% 
          addTiles() %>%
          addMarkers(lng = log, lat = lati , popup = "test",label = "a")
       }
      )

      selectedData <- reactive({
        m
      })

      output$info <- renderPrint({
        selectedData()
      })     
    }

    shinyApp(ui, server)

Comment: The main panel should have plotted with the leaflet map

我正在尝试根据用户输入两个文本字段(即经度和纬度)在地图上绘制坐标

从那时起,我是R编程的新手。希望得到积极的回应。谢谢。

1 个答案:

答案 0 :(得分:0)

您必须注释(#)您的titlepanel和SideBarLayout部分。您已经离开了它们,它们作为您代码的一部分运行。