用传单映射

时间:2018-08-08 14:03:18

标签: r shiny r-leaflet

我是刚接触光泽并尝试使用传单进行映射的人。尽管我已经有了qgs格式的地图图层,如何使用这些qgis图层并制作自定义的tile(图层)进行交互式映射?希望将qgis层转换为小叶映射格式的指导。

这是QGIS中各层的图像: Map Layers in QGIS

1 个答案:

答案 0 :(得分:0)

您可以使用例如添加图层addWMSTiles。下面是一个可行的示例,该示例将QGIS图层添加到交互式leaflet闪亮应用程序中。

library(shiny)
library(leaflet)
library(leaflet.extras)

ui <- fluidPage(
  leafletOutput("mymap")
)

server <- function(input, output, session) {
  output$mymap <- renderLeaflet({
    leaflet(
      options = leafletOptions(
        center = c(-33.95293, 20.82824),
        zoom = 14,
        minZoom = 5,
        maxZoom = 18,
        maxBounds = list(
          c(-33.91444, 20.75351),
          c(-33.98731, 20.90626)
        )
      )
    ) %>%
      addWMSTiles(
        baseUrl = paste0(
          "http://maps.kartoza.com/web/?",
          "map=/web/Boosmansbos/Boosmansbos.qgs"
        ),
        layers = "Boosmansbos",
        options = WMSTileOptions(format = "image/png", transparent = TRUE),
        attribution = paste0(
          "(c)<a href= \"http://kartoza.com\">Kartoza.com</a> and ",
          "<a href= \"http://www.ngi.gov.za/\">SA-NGI</a>"
        )
      ) %>%
      addWMSLegend(
        uri = paste0(
          "http://maps.kartoza.com/web/?",
          "map=/web/Boosmansbos/Boosmansbos.qgs&&SERVICE=WMS&VERSION=1.3.0",
          "&SLD_VERSION=1.1.0&REQUEST=GetLegendGraphic&FORMAT=image/jpeg&LAYER=Boosmansbos&STYLE="
        )
      )
  })
}

shinyApp(ui, server)

Shiny Leaflet App