有人能告诉我为什么传单没有读取在shine的服务器功能中正确创建的数据框架吗?当我试图根据之前收集的数据添加CircleMarkers时,它在执行时不会显示任何映射?它工作得很完美,当我在没有输入$type和";共同工作;作为search_string和关键字。
library(shiny)
library(shinydashboard)
library(leaflet)
library(rgdal)
library(dplyr)
library(data.table)
library(leaflet.extras)
library(googleway)
library(tidyverse)
dashboard <- dashboardPage(
skin = "blue",
dashboardHeader(title = "Cluster-Dashboard"),
dashboardSidebar(
textInput("type", "Nutzung")),
dashboardBody(
fluidRow(box(width = 12, leaflet::leafletOutput(outputId = "mymap"))),
fluidRow(box(width = 12, dataTableOutput(outputId = "Coworking")))
))
db_server <- function(input, output) {
# gathering data and cleaning it
output$Coworking <- renderDataTable({
Coworking_2 <- google_places(
search_string = input$type,
location = c(52.52639577069,13.342801700749),
radius = 0.5,
keyword = input$type,
simplify = TRUE,
key = "Hidden")
keeps <- c("name", "formatted_address", "geometry", "place_id")
CoWorking_Clean = Coworking_2$results[keeps]
CoWorking_Clean_2 <- CoWorking_Clean %>%
unnest(geometry) %>%
unnest(location) %>%
subset(select = c("name", "formatted_address", "lat", "lng", "place_id")) %>%
rename(address = "formatted_address")
})
output$mymap <- reactive({leaflet::renderLeaflet({Karte})})
Karte <- reactive({
leaflet (output$Coworking) %>%
addTiles() %>%
addProviderTiles(providers$CartoDB.PositronNoLabels) %>%
setView(13.412, 52.505, zoom = 11) %>%
addCircleMarkers(popup = ~as.character(name), label = ~as.character(name),fill =TRUE, fillColor ="#225287", stroke =FALSE, opacity = 0.5, group = "Companies",
labelOptions = labelOptions(noHide = T, textOnly = TRUE, direction = "bottom", style = list("color" = "black", "font-size" = "11px", "font-family" = "AkkuratStd", "font-style" = "Thin")))
}
)}
shinyApp (ui = dashboard , server = db_server)
dataTableOutput";共同工作;澄清了数据表已经创建,信息应该能够通过传单阅读。里面有long和lat。我吓坏了。。。。
没有任何错误,这个闪亮的应用程序会立即加载,除了传单地图之外,一切都很完美。甚至没有错误。。。
我在服务器函数中发现了一些错误,但由于api令牌的原因,我无法测试下面的代码是否解决了问题。
db_server <- function(input, output) {
cowork <- reactive({
Coworking_2 <- google_places(
search_string = input$type,
location = c(52.52639577069,13.342801700749),
radius = 0.5,
keyword = input$type,
simplify = TRUE,
key = "Hidden")
keeps <- c("name", "formatted_address", "geometry", "place_id")
CoWorking_Clean = Coworking_2$results[keeps]
CoWorking_Clean_2 <- CoWorking_Clean %>%
unnest(geometry) %>%
unnest(location) %>%
subset(select = c("name", "formatted_address", "lat", "lng", "place_id")) %>%
rename(address = "formatted_address")
return(CoWorking_Clean_2)
})
output$Coworking <- renderDataTable({
cowork()
})
output$mymap <- renderLeaflet({
leaflet (cowork()) %>%
addTiles() %>%
addProviderTiles(providers$CartoDB.PositronNoLabels) %>%
setView(13.412, 52.505, zoom = 11) %>%
addCircleMarkers(popup = ~as.character(name), label = ~as.character(name),fill =TRUE, fillColor ="#225287", stroke =FALSE, opacity = 0.5, group = "Companies",
labelOptions = labelOptions(noHide = T, textOnly = TRUE, direction = "bottom", style = list("color" = "black", "font-size" = "11px", "font-family" = "AkkuratStd", "font-style" = "Thin")))
})
}