addTangram: Adds a Tangram layer to a Leaflet map in a Shiny App.

View source: R/tangram.R

addTangramR Documentation

Adds a Tangram layer to a Leaflet map in a Shiny App.

Description

Adds a Tangram layer to a Leaflet map in a Shiny App.

Usage

addTangram(map, scene = NULL, layerId = NULL, group = NULL, options = NULL)

Arguments

map

A leaflet map widget

scene

Path to a required .yaml or .zip file. If the file is within the /www folder of a Shiny-App, only the filename must be given, otherwise the full path is needed. See the Tangram repository or the Tangram docs for further information on how to edit such a .yaml file.

layerId

A layer ID

group

The name of the group the newly created layer should belong to (for clearGroup and addLayersControl purposes).

options

A list of further options. See the app in the examples/tangram folder or the docs for further information.

Value

the new map object

Note

Only works correctly in a Shiny-App environment.

References

https://github.com/tangrams/tangram

Examples

## Not run: 
library(shiny)
library(leaflet)
library(leaflet.extras2)

## In the /www folder of a ShinyApp. Must contain the Nextzen API-key
scene <- "scene.yaml"

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

server <- function(input, output, session) {
  output$map <- renderLeaflet({
    leaflet() %>%
      addTiles(group = "base") %>%
      addTangram(scene = scene, group = "tangram") %>%
      addCircleMarkers(data = breweries91, group = "brews") %>%
      setView(11, 49.4, 14) %>%
      addLayersControl(baseGroups = c("tangram", "base"),
                       overlayGroups = c("brews"))
  })
}

shinyApp(ui, server)

## End(Not run)

leaflet.extras2 documentation built on Aug. 21, 2023, 5:08 p.m.