将弹出窗口改为标签
弹出窗口很好用,但需要额外的操作。这时标签就能派上用场。在 addCircleMarkers() 函数中使用 label 参数,您只需将鼠标悬停即可获取某个标记的更多信息!
ipeds %>%
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(label = ~name, radius = 2)
当要绘制的不止少数位置时,标签尤其有帮助,因为它能快速说明每个标记所代表的内容。
本练习是课程的一部分
在 R 中使用 leaflet 构建交互式地图
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Add circle markers with labels identifying the name of each college
map %>%
addCircleMarkers(data = ca, radius = 2, label = ___)