forked from IkeLyons/HUB-map
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.R
More file actions
40 lines (34 loc) · 1.03 KB
/
map.R
File metadata and controls
40 lines (34 loc) · 1.03 KB
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
library(magrittr)
library(leaflet)
library(htmlwidgets)
library(readr)
geocoded_list <- read_csv("geocoded-list.csv")
data <- geocoded_list
getColor <- function(data) {
sapply(data$followers, function(followers) {
if(followers <= 1000) {
"green"
} else if(followers <= 10000) {
"orange"
} else {
"red"
} })
}
icons <- awesomeIcons(
icon = 'ios-close',
iconColor = 'black',
library = 'ion',
markerColor = getColor(data)
)
m <- leaflet(data = geocoded_list) %>%
addTiles() %>%
setView( lng = 2.349014, lat = 48.864716, zoom = 12 ) %>%
addAwesomeMarkers(label = ~name, popup = ~as.character(followers), icon=icons, group = "Follow Count") %>%
addMarkers(clusterOptions = markerClusterOptions(), popup = ~as.character(followers), group = "Clusters") %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addLayersControl(
baseGroups = c("Follow Count", "Clusters"),
options = layersControlOptions(collapsed = FALSE)
)
m
saveWidget(m, file=paste0(getwd(), "/backgroundMapTile.html"))