我正在尝试创建具有巴西状态的地图,当我在UI文件中运行此代码时,效果很好。但是我需要创建一个反应式映射,所以我将其写在服务器文件上。
地图可以很好地绘制,但形状数据却没有...有帮助吗?
server <- shinyServer(function(session, input, output) {
BrasilianStates <- readOGR("UFEBRASIL.shp",encoding = "UTF-8")
output$map <- renderLeaflet
({ #RENDERIZACAO DO MAPA
leaflet(data = BrasilianStates) %>% addTiles()%>%
addMarkers(data= CDDs,icon = iconeCDD, popup = nomes, clusterOptions = markerClusterOptions())%>%
addPolygons(data = BrasilianStates,weight = 2,
opacity = 1,
color = "#660000",
dashArray = "3",
fillOpacity = 0.7, highlight = highlightOptions(weight = 5, color = "#666",dashArray = "", fillOpacity = 0.7,
bringToFront = TRUE)) })
仅在控制台中运行时:
leaflet(data = BrasilianStates) %>% addTiles()%>%
addMarkers(data= CDDs,icon = iconeCDD, popup = nomes, clusterOptions = markerClusterOptions())%>%
addPolygons(data = BrasilianStates)
这些图可以在RStudio右侧的查看器选项卡中完美地工作。
但是当我尝试使用闪亮的应用程序中的服务器文件时,它不会呈现。