Comments (6)
@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.
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.
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.
I think you can just replace observe() with renderLeaflet().
from leaflet.
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.
Thanks for assistance
from leaflet.
Related Issues (20)
- Group layers within categories in overlayGroups parameter in addLayersControl function
- Security: Update Bootstrap version HOT 3
- leaflet is dependent on R3.6.0 via leaflet.providers, not R3.1.0 as per DESCRIPTION HOT 4
- DESCRIPTION should require minimum version for `raster` to avoid test failures HOT 8
- Problem when measuring distances in square kilometers
- Stamen Tile Deprecation Warning HOT 3
- Release leaflet 2.2.1
- Layer control fails when using clusterOptions
- Leaflet Map not loading after window size changes
- htmlwidgets 1.6.3 breaks addEasyButton HOT 1
- Update of map not works HOT 1
- addPolyline() with SpatVector fails if terra is not loaded because check_crs_terra() is missing depency terra::crs HOT 2
- toggle baseGroups legends in the same way as overlayGroups in addLayersControl HOT 1
- Proj4Leaflet-TMS.R example is broken; broken TMS in Leaflet is possibly the culprit! HOT 2
- tms = TRUE not working with known TMS provider (from NASA!) HOT 2
- Leaflet muddling RGB rasters from terra
- No documentation on the Polyline 'offset' functionality
- Error in addLegend: unused arguments HOT 2
- addTiles does not allow display of self-hosted vector tiles
- Specifying labels as zero-length character vector causes error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet.