Make the leaflet and tidyverse packages available. This implies that you have already installed them on your computer.
library(leaflet)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 1.0.1
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.3.0 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
Use Leaflet to display your central location, probably the address where you live.
# Place your code here.
myLong = -122.819268
myLat = 47.0404364
leaflet() %>%
addTiles() %>%
addMarkers(myLong,myLat,popup = "My House")
Use Leaflet with the default tiles to display the locations in your myLocs file.
# Place your code here.
myLocs = read_csv("myLocs.csv")
## Rows: 4 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): ID
## dbl (2): lat, lon
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
myMap = myLocs %>%
leaflet() %>%
addTiles() %>%
addMarkers(popup = ~ID)
## Assuming "lon" and "lat" are longitude and latitude, respectively
myMap
Do that again with a different provider.
# Place your code here.
myMap = myLocs %>%
leaflet() %>%
addProviderTiles("Stamen") %>%
addMarkers(popup = ~ID)
## Assuming "lon" and "lat" are longitude and latitude, respectively
myMap
Do that again with another provider.
# Place your code here.
myMap = myLocs %>%
leaflet() %>%
addProviderTiles("Esri.NatGeoWorldMap") %>%
addMarkers(popup = ~ID)
## Assuming "lon" and "lat" are longitude and latitude, respectively
myMap
Which provider looks best to you? No code, just write.
To me, I prefer the Esri Map because I prefer to have color on my map compare to the black and white using Stamen.