將彈出視窗改成標籤
彈出視窗很好用,但需要多一步操作。這時就輪到標籤上場了。使用 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 = ___)