Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen option in R package leaflet?

Tags:

r

leaflet

shiny

The following code produces a shiny app with (almost) the same output twice. One uses package "rcharts", the other package "leaflet"

The first map has a fullsreen button. Is this available with package leaflet()?

library(shiny)
library(rCharts)
library(leaflet)

runApp(

  ## UI ####
  list(ui = (basicPage(
    headerPanel("tests"),
    mainPanel(
      chartOutput("map1", "leaflet"),
      "some text...",
      leafletOutput('map2')
    )
  )),

  ## server ####
  server = function(input, output) {

    output$map1  <- renderMap({
      map1 <- Leaflet$new()
      map1$fullScreen(TRUE)
      map1$setView(c(39.603609, -8.415081), 10)
      map1
    })

    output$map2 <- renderLeaflet({
      leaflet() %>%
        addTiles() %>%
        setView(lng = -8.415081, lat = 39.603609, zoom = 10)
    })
    }
      ))

Thanks

like image 832
marxco Avatar asked Jan 25 '16 23:01

marxco


2 Answers

For future readers

With the package leaflet.extras you can add a full screen control to your map.

library(leaflet)
library(leaflet.extras)
leaflet() %>%
    addTiles() %>%
    addFullscreenControl()
like image 111
Wilmar van Ommeren Avatar answered Nov 05 '22 23:11

Wilmar van Ommeren


There is a plugin for the Leaflet javascript library called Leaflet.Control.FullScreen.

However, this plugin hasn't (yet) been implemented in the R version of leaflet. I have posted a feature request on the leaflet Github page, but haven't heard anything back so far.

like image 28
Tiernan Avatar answered Nov 06 '22 00:11

Tiernan