我在使用addWMSTiles添加我国家/地区的WMS图层时遇到了问题。
我只看到Open Street底图而不是WMS图层。
你知道为什么吗?
非常感谢。
这是我的Ui.R:
library(shiny)
library(leaflet)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(
title = "New Caledonia",
titleWidth = 500),
dashboardSidebar(
sidebarMenu(
id = "Menu1",
menuItem(strong("Map"), tabName = "Map", icon = icon("globe"),selected = TRUE)
)
),
dashboardBody(
tags$head(tags$style(HTML('
.main-header .logo {
font-family: "Georgia", Times, "Times New Roman", serif;
font-weight: bold;
font-size: 16px;
}
'))),
tabItems(
tabItem(tabName = "Map",
fluidRow(
box(
title = "Map test",
collapsible = TRUE,
width = "100%",
height = "850px",
solidHeader = TRUE,
status = "primary",
leafletOutput("mymap",width="100%",height="850px"))
)
)
)
)
)
这是我的Server.R:
shinyServer(function(input, output, session) {
output$mymap <- renderLeaflet({
leaflet(height = "100%") %>%
addTiles() %>%
setView(165.538323, -21.403740, zoom = 8) %>%
addWMSTiles(
"https://carto.gouv.nc:443/public/services",
layers = "fond_imagerie",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
attribution = "Gouvernement de la Nouvelle-Calédonie"
)
})
})
如果您有任何想法,请告诉我。
谢谢。