尝试使用数据框和筛选器创建类似one的地图时,我发现leaflet没有正确反映经度或纬度,并且没有弹出窗口显示。dataset & css。
代码:
我附上了我在应用程序中使用的CSS以及所有需要的data。如果我删除
提前感谢您。
代码:
library(shiny)
library(dplyr)
library(leaflet)
library(readr)
CBdata <- read_csv("/cloud/project/TESTLEAF/www/cblnglt.csv")
df0<- data.frame("cho"=c("No schooling completed","vocational","Bachelor","Post Graduate ","Single","Married","Divorced","others","male","female","under_20","21_30","31_39","31_40","41_50","51_59","over_60","Retired","Public_Employee","Private_Employee","Self_employeed","Unemployed","Others"),
"cat"=c("educ.","educ.","educ.","educ.","Relationship.Status","Relationship.Status","Relationship.Status","Relationship.Status","by_gender","by_gender","By_age","By_age","By_age","By_age","By_age","By_age","By_age","profession","profession","profession","profession","profession","profession"))
CBdata2<-as.data.frame(CBdata)
ui<-
navbarPage("Mapping Dashboard",
theme = "bootstrap.css",
tabPanel("tbd",
div(class="outer",
leafletOutput("mymap", width = "100%", height = "100%"), #
absolutePanel(id = "controls", class = "panel panel-default",
fixed = TRUE,draggable = TRUE, top = "10%", left = "auto", right = 20, bottom = "auto",
width = 330, height = "auto", cursor = "move",br(),
selectInput("region", "Which governorate?", unique(CBdata$by_gov), selected = "Mumbai"),
selectInput("variable", "Filter by?", unique(df0$cat), selected = "by_gender"),
selectInput("sndvariable","sub filter",choices =NULL),
selectInput("indicator","select Indicator",c("xyz","abc"),
selected = "abc"),
plotOutput("bar", height = "250px"),
))),
tabPanel("By Product"))
server<-function(input,output,session){
observe({
TX<-df0%>%filter(cat==input$variable)%>%select(cho)
updateSelectInput(session,"sndvariable","sub filter",choices = unique(TX))
})
CBD1<-reactive({
#browser
CBdata2%>%
filter(input$variable==input$sndvariable,by_gov==input$region)%>%
group_by(lng,lat,input$variable,by_gov,input$indicator)%>%
arrange(desc(input$indicator)) %>%
select(lng,lat,input$variable,by_gov,input$indicator)
})
CBD2<-reactive({
#browser
summarize(CBD1(),summation=sum(as.integer(input$indicator)))
})
CBD3<-reactive({as.data.frame(CBD2())
})
output$mymap<-renderLeaflet({
CBD3()%>%leaflet()%>%
addProviderTiles(provider = "CartoDB.DarkMatter")%>%
addCircleMarkers(lng=~lng,lat=~lat)
})
}
shinyApp(ui,server)
我附上了我在应用程序中使用的CSS以及所有需要的data。如果我删除
lng=~lng
并插入实际值,它可以正常工作,但当我们使用数据框时出现问题。提前感谢您。