【发布时间】:2017-12-10 22:26:16
【问题描述】:
我在 shinyapps 中使用传单库。我正在尝试根据用户输入下拉选择显示我保存为图标的标记。在下面的示例中,我无法根据用户输入过滤掉标记。当我只使用不带光泽的传单包运行时,类似的代码也有效。
下面的示例代码在 Shiny 的 server.r 中。
filteredData <- reactive({
sampling_data[sampling_data$county == input$county_select, ]
})
theData <- filteredData()
leafletProxy("mapData") %>%
clearMarkers() %>%
addMarkers(lng = sampling_data$lon,
lat = sampling_data$lat,
clusterOptions = markerClusterOptions())
})
output$mapData <- renderLeaflet({
leaflet(sampling_data) %>%
addProviderTiles(providers$Esri.WorldTopoMap) %>%
setView(lng = -75, lat = 43, zoom = 6)
})
observe({
theData <- filteredData()
leafletProxy("mapData") %>%
clearMarkers() %>%
addMarkers(lng = sampling_data$lon,
lat = sampling_data$lat,
clusterOptions = markerClusterOptions())
})
这段代码,没有光泽,工作正常
subsetData <- sampling_data %>%
filter(county == "Albany")
leaflet(subsetData) %>%
addTiles() %>%
addMarkers(lng = ~lon,
lat = ~lat)
【问题讨论】:
-
你能把代码分享给 addCirceMarkers 吗?
-
嗨@Seymour。我在提出问题时犯了一个错误。我的意思是说代码可以在没有闪亮的情况下使用传单。但是,在有光泽的情况下运行传单时它会中断。