The objective of this project is to create a map using the leaflet package in R.
For the sake of this project I am creating a simple map showing where I am sitting right now, where I live and where I work! This gives you, dear reviewer, an idea of my current habitat! :)
I also include the R codes in case you want to see how the maps are generated:
library(leaflet)
df <- data.frame(lat = c(49.248558, 49.274840, 49.179692),
lng = c(-123.100629, -123.124272, -123.084344),
col = c("green", "red", "blue"))
df %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(weight = 1, color = df$col) %>%
addLegend(labels = c("Current Location", "Home", "Work"), colors = c("green", "red", "blue"))
To make it a little appealing I replace the circle markers with 3 icons (and popup messages) representing the current location, home and work:
library(leaflet)
df <- data.frame(lat = c(49.248558, 49.274840, 49.179692),
lng = c(-123.100629, -123.124272, -123.084344),
pop = c("Current Location", "Home", "Work"))
iconlist = icons(iconUrl = c("https://png.icons8.com/dusk/40/000000/marker.png",
"https://png.icons8.com/office/50/000000/home-page.png",
"https://png.icons8.com/cotton/40/000000/business.png"),
iconWidth = 30, iconHeight = 30)
df %>%
leaflet() %>%
addTiles() %>%
addMarkers(icon = iconlist, popup = df$pop)
This is the end of the project! See you in a week!