Theme
Rmarkdown html theme:
Leaflet map
This is the code to generate my leaflet map:
# installing and/or loading required packages:
if (!"leaflet" %in% rownames(installed.packages())) {install.packages("leaflet")}
library(leaflet)
if (!"exifr" %in% rownames(installed.packages())) {install.packages("exifr")}
library(exifr)
if (!"leafpop" %in% rownames(installed.packages())) {install.packages("leafpop")}
library(leafpop)
if (!"htmlwidgets" %in% rownames(installed.packages())) {install.packages("htmlwidgets")}
library(htmlwidgets)
#listing my photos:
files <- list.files(path = "./my_photos/", pattern = "*.jpg", full.names=TRUE)
#reading the exif info from photos:
dat <- read_exif(files)
# creating a dataframe with the coordinates from photos:
dat_df <- data.frame(lat = dat$GPSLatitude, long = dat$GPSLongitude)
# creating a leaflet map with my georeferenced photos:
my_map <- leaflet() %>%
addTiles() %>%
addMarkers(data = dat_df, group = "points") %>%
addPopupImages(files, group = "points")
# exporting the leaflet object to a html file:
saveWidget(my_map, file="my_map.html")
After export the leaflet object as a html file i hosted it here.
To embed the leaflet object to this page i inserted this code in the html file:
<iframe src="https://danilovcorrea.neocities.org/" frameborder="0" width="900px" height="675px"></iframe>