Aan de slagGa gratis aan de slag

Building a Better Pop-up

With the paste0() function and a few html tags, we can customize our popups. paste0() converts its arguments to characters and combines them into a single string without separating the arguments.

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

We can use the <br/> tag to create a line break to have each element appear on a separate line.

To distinguish different data elements, we can make the name of each college italics by wrapping the name variable in <i></i>

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

Deze oefening maakt deel uit van de cursus

Interactive Maps with leaflet in R

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Clear the bounds and markers on the map object and store in map2
map2 <- map %>% 
            ___() %>% 
            ___()
Code bewerken en uitvoeren