Learn R Programming

leafgl (version 0.1.1)

renderLeafgl: Use leafgl in shiny

Description

Use leafgl in shiny

Usage

renderLeafgl(expr, env = parent.frame(), quoted = TRUE)

Arguments

expr

An expression that generates an HTML widget (or a promise of an HTML widget).

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Value

A server function for rendering leafgl

Examples

Run this code
# NOT RUN {
if (interactive()) {
library(leaflet)
library(leafgl)
library(sf)
library(shiny)

n = 1e4
df1 = data.frame(id = 1:n,
    x = rnorm(n, 10, 3),
    y = rnorm(n, 49, 1.8))
pts = st_as_sf(df1, coords = c("x", "y"), crs = 4326)

m = leaflet() %>%
 addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
 addGlPoints(data = pts, group = "pts") %>%
 setView(lng = 10.5, lat = 49.5, zoom = 6) %>%
 addLayersControl(overlayGroups = "pts")

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

server <- function(input, output, session) {
    output$mymap <- renderLeaflet(m)
}

shinyApp(ui, server)
}

# }

Run the code above in your browser using DataLab