在 R 中使用 leaflet 构建交互式地图
Rich Majerus
Vice President of Strategy & Planning, Queens University of Charlotte
ipeds %>%
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(
lng = ~lng,
lat = ~lat,
popup = ~name,
color = "#FF0000")

# ipeds 被指定了 3 次
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(
lng = ipeds$lng,
lat = ipeds$lat,
popup = ipeds$name,
color = "red")

ipeds %>%
leaflet() %>%
addProviderTiles("CartoDB")%>%
addCircleMarkers(
lng = ~lng, lat = ~lat,
popup = ~name,color = "#FF0000")
| 十六进制 | 十进制 | RGB 颜色 |
|---|---|---|
| FF | 255 | 红 |
| 00 | 0 | 绿 |
| 00 | 0 | 蓝 |

= 16^1*15 + 16^0*15
= 16*15 + 1*15
= 240 + 15
= 255
addCircleMarkers(popup = ~name)addCircleMarkers(popup = ~paste0(name, "-", sector_label)addCircleMarkers(popup = ~paste0("<b>",name,"</b>"," <br/>",sector_label))

ipeds %>%
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(label = ~name, radius = 2)

在 R 中使用 leaflet 构建交互式地图