Giter VIP home page Giter VIP logo

Comments (6)

yihui avatar yihui commented on June 19, 2024 1

@jjallaire Exactly. Here is a minimal example:

---
output: html_document
runtime: shiny
---

Test leaflet

```{r}
library(leaflet)
library(shiny)
sliderInput('n', 'Number of markers', min = 1, max = 100, value = 30, step = 1)
renderLeaflet({
  n = input$n
  df = data.frame(lat = rnorm(n, 42), lng = rnorm(n, -93))
  leaflet(df) %>% addTiles() %>% addMarkers()
})
```

from leaflet.

yihui avatar yihui commented on June 19, 2024

It is just like all traditional Shiny output elements, i.e. use leafletOutput(id) in ui.R, and output$id = renderLeaflet(leaflet() %>% addTiles() %>% ...) in server.R.

from leaflet.

pssguy avatar pssguy commented on June 19, 2024

I was hoping to code directly in Rmarkdown without the need to wrap it in an embedded shinyApp
That is my normal practice if I want to display dataTables or ggvis plots, for example
However, it is no big deal as I have gone the embedding route and seems to work fine

from leaflet.

yihui avatar yihui commented on June 19, 2024

I think you can just replace observe() with renderLeaflet().

from leaflet.

jjallaire avatar jjallaire commented on June 19, 2024

I think you just need to add runtime: shiny to the YAML and then you can use leaflet in reactives. It would be something like this:

renderLeaflet({

   data <- calcs involving input$var

   glimpse(data) # confirmscorrect values in console

   leaflet(data) %>% 
      addTiles() %>% 
      addCircleMarkers(info based on data)

})

@yihui does that look right?

from leaflet.

pssguy avatar pssguy commented on June 19, 2024

Thanks for assistance

from leaflet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.