knitr::opts_chunk$set(echo = TRUE) # Display code in the output document library(leaflet) # Load the leaflet package for map creation library(magrittr) # Load magrittr for the %>% pipe operator
map <- leaflet() %>% addTiles()
chennaiCentralIcon <- makeIcon( iconUrl = “https://cdn.iconscout.com/icon/free/png-512/chennai-1-119692.png”, # URL of the icon image iconWidth = 30 * 408 / 255, # Adjust width according to image ratio iconHeight = 30, # Set fixed height iconAnchorX = 30 * 408 / 255 / 2, # Set the anchor for the X-axis (position of the marker) iconAnchorY = 30 / 2 # Set the anchor for the Y-axis (position of the marker) )
chennaiCentralPopup <- c(
“
Chennai Central
”
)
map <- map %>% addMarkers( lat = 13.0828, # Latitude of Chennai Central lng = 80.2753, # Longitude of Chennai Central popup = chennaiCentralPopup, # Attach the popup content icon = chennaiCentralIcon # Use the custom icon for the marker )
map
summary(cars)
plot(pressure)