Interactive Maps In a Book!

Author

Tuhin Rana

Published

March 15, 2023

1 Introduction

This is a book created from markdown and executable code.

Testing Leaflet Maps into a book! Lets see!

1.1 Libraries

library(magrittr)
library(leaflet)
library(readxl)

1.2 This is The Data to plot on a map.

Area_of_Collection <- read_excel("Area of Collection.xlsx")
rmarkdown::paged_table(head(Area_of_Collection))

And This is the output!

1.3 Map

leaflet(Area_of_Collection) %>%
  addTiles() %>%
  addMarkers(
    lng = ~ Lon,
    lat = ~ Lat,
    popup = paste0(Area_of_Collection$Name, "<br>", "Market Code: ", Area_of_Collection$`Market Code`),
    popupOptions = popupOptions(closeButton = F)
  )

1.4 Diffrent Styles

1.4.1 Esri

leaflet(Area_of_Collection) %>%
  addProviderTiles(providers$Esri) %>%
  addMarkers(
    lng = ~ Lon,
    lat = ~ Lat,
    popup = paste0(Area_of_Collection$Name, "<br>", "Market Code: ", Area_of_Collection$`Market Code`),
    popupOptions = popupOptions(closeButton = F)
  )

1.4.2 CartoDb

leaflet(Area_of_Collection) %>%
  addProviderTiles(providers$CartoDB) %>%
  addMarkers(
    lng = ~ Lon,
    lat = ~ Lat,
    popup = paste0(Area_of_Collection$Name, "<br>", "Market Code: ", Area_of_Collection$`Market Code`),
    popupOptions = popupOptions(closeButton = F)
  )