R Markdown

The following map shows an map of some of the popular capital cities in Europe - London, Madrid, Rome, Paris, and Valletta.

library(leaflet)
library(dplyr)
dt <- data.frame(
                city = c('London', 'Madrid', 'Rome', 'Paris', 'Valletta'),
                lng = c(-0.083333, -3.683333, 12.483333, 2.333333, 14.5),
                lat = c(51.5, 40.4, 41.9, 48.86666667, 35.88333333),
                col = c("red", "orange", "yellow", "lightgreen", "blue")
                )

dt$popup <- with(dt, paste("<b>", city, "</b>"))

markers <- awesomeIcons(
    icon='map-marker',
    iconColor = 'black',
    markerColor = dt$col,
    library='fa')

m <- leaflet(data = dt, width = "100%" ) %>%
    addTiles() %>%  # Add default OpenStreetMap map tiles
    addAwesomeMarkers(
        lng = ~lng, 
        lat = ~lat, 
        popup = ~popup,
        icon = markers
    ) %>%
    addLegend(
        position='topright',
        colors= c("red", "orange", "yellow", "lightgreen", "blue"),
        labels= dt$city,
        opacity = 0.75,
        title="Legend"
        )

m  # Show map