The source code is available at GitHub. Just click here!

My First Leaflet Map

Create a leaflet map object.

library(leaflet)
map <- leaflet() %>% addTiles()

Create a marker with a picture of Chennai Central and a link to its homepage.

chennaiCentralIcon <- makeIcon(
   iconUrl = "https://cdn.iconscout.com/icon/free/png-512/chennai-1-119692.png",
   iconWidth = 30*408/255, iconHeight = 30,
   iconAnchorX = 30*408/255/2, iconAnchorY = 30/2
)

Add the marker to the map and display the map.

chennaiCentralPopup <- c("<a href= 'https://en.wikipedia.org/wiki/Chennai_Central_railway_station' >Chennai Central<br><img src='https://cdn.iconscout.com/icon/free/png-512/chennai-1-119692.png' width='210' height='132'  alt='Chennai Central' title='Chennai Central'></a>")
map %>%
   addTiles() %>%
   addMarkers(lat=13.0828, lng=80.2753, popup = chennaiCentralPopup)