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