christophe dervieux | 65b5604 | 2021-09-17 10:00:44 +0200 | [diff] [blame] | 1 | --- |
| 2 | title: "Rmarkdown Presentation including Leaflet" |
| 3 | output: |
| 4 | revealjs::revealjs_presentation |
| 5 | --- |
| 6 | |
| 7 | ```{r, include = FALSE} |
| 8 | knitr::opts_chunk$set(echo = FALSE) |
| 9 | knitr::opts_template$set(demo = list(echo = TRUE, eval = FALSE)) |
| 10 | library(leaflet) |
| 11 | ``` |
| 12 | |
| 13 | |
| 14 | # Simple map |
| 15 | |
| 16 | ```{r simple} |
| 17 | m <- leaflet() %>% |
| 18 | addTiles() %>% # Add default OpenStreetMap map tiles |
| 19 | addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R") |
| 20 | m |
| 21 | ``` |
| 22 | |
| 23 | ## Code |
| 24 | |
| 25 | ```{r simple, opts.label = "demo"} |
| 26 | ``` |
| 27 | |
| 28 | # More complex example |
| 29 | |
| 30 | ```{r popups} |
| 31 | library(htmltools) |
| 32 | |
| 33 | df <- read.csv(textConnection( |
| 34 | "Name,Lat,Long |
| 35 | Samurai Noodle,47.597131,-122.327298 |
| 36 | Kukai Ramen,47.6154,-122.327157 |
| 37 | Tsukushinbo,47.59987,-122.326726" |
| 38 | )) |
| 39 | |
| 40 | leaflet(df) %>% addTiles() %>% |
| 41 | addMarkers(~Long, ~Lat, popup = ~htmlEscape(Name)) |
| 42 | ``` |
| 43 | |
| 44 | ## Code |
| 45 | |
| 46 | ```{r popups, opts.label = "demo"} |
| 47 | ``` |
| 48 | |