Labels and Pop-ups

Interactive Maps with leaflet in R

Rich Majerus

Vice President of Strategy & Planning, Queens University of Charlotte

Piping และ ~ Operator

ipeds %>% 
 leaflet() %>% 
 addProviderTiles("CartoDB") %>% 
 addCircleMarkers(
               lng = ~lng, 
               lat = ~lat, 
               popup = ~name, 
               color = "#FF0000")

วงกลมมาร์กเกอร์ของวิทยาลัยทั้งหมด 1

# ipeds is specified 3 times
leaflet() %>% 
  addProviderTiles("CartoDB") %>% 
  addCircleMarkers(
              lng = ipeds$lng, 
              lat = ipeds$lat, 
              popup = ipeds$name, 
              color = "red")

วงกลมมาร์กเกอร์ของวิทยาลัยทั้งหมด 2

Interactive Maps with leaflet in R

สีทั้งหมด

ipeds %>% 
     leaflet() %>% 
     addProviderTiles("CartoDB")%>% 
     addCircleMarkers(
        lng = ~lng, lat = ~lat, 
        popup = ~name,color = "#FF0000")
Hex Decimal RGB Color
FF 255 Red
00 0 Green
00 0 Blue

Hex FF0000

= 16^1*15 + 16^0*15

= 16*15 + 1*15

= 240 + 15

= 255

Interactive Maps with leaflet in R

สร้าง Pop-up ให้ดีขึ้น

addCircleMarkers(popup = ~name)

addCircleMarkers(popup = ~paste0(name, "-", sector_label)
addCircleMarkers(popup = ~paste0("<b>",name,"</b>"," <br/>",sector_label))

Pop-up แบบกำหนดเอง

Interactive Maps with leaflet in R

Labels

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

Label แบบกำหนดเอง

Interactive Maps with leaflet in R

มาฝึกกันเถอะ!

Interactive Maps with leaflet in R

Preparing Video For Download...