-
Notifications
You must be signed in to change notification settings - Fork 8
/
01_leaflet.R
76 lines (60 loc) · 1.73 KB
/
01_leaflet.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Crosstalk: Shiny-like without Shiny (EARL 18, London, Sep 2018)
# Blurb: https://earlconf.com/2018/london/#matt-dray
# Matt Dray
# July 2018
# This file: create a leaflet html file
# Leaflet for R: https://rstudio.github.io/leaflet/
# Prep workspace ----------------------------------------------------------
sch <- readRDS("data/gias_sample.RDS")
library(dplyr) # tidy data manipulation
library(leaflet) # interative mapping
# Map ---------------------------------------------------------------------
map <- sch %>%
leaflet::leaflet() %>%
leaflet::addProviderTiles(providers$OpenStreetMap) %>%
leaflet::addAwesomeMarkers(
popup = ~paste0(
"<h1>", sch$sch_name, "</h1>",
"<table style='width:100%'>",
"<tr>",
"<th>URN</th>",
"<th>", sch$sch_urn, "</th>",
"</tr>",
"<tr>",
"<tr>",
"<th>Phase</th>",
"<th>", sch$sch_phase, "</th>",
"</tr>",
"<tr>",
"<tr>",
"<th>Type</th>",
"<th>", sch$sch_type, "</th>",
"</tr>",
"<tr>",
"<tr>",
"<th>Location</th>",
"<th>", sch$geo_town, ", ", sch$geo_postcode, "</th>",
"</tr>",
"<tr>",
"<tr>",
"<th>LA</th>",
"<th>", sch$geo_la, "</th>",
"</tr>"
), # end popup()
icon = awesomeIcons(
library = "ion",
icon = ifelse(
test = sch$ofsted_rating == "1 Outstanding",
yes = "ion-android-star-outline",
no = "ion-android-radio-button-off"
),
iconColor = "white",
markerColor = ifelse(
test = sch$sch_phase == "Primary",
yes = "red",
no = "blue"
)
)
) %>% # end addAwesomeMarkers()
leaflet::addMeasure()
print(map)