## Load necessary libraries
library(ggplot2)
library(ggmap)
library(dplyr)
library(gt)
## Load sitemaps
## library(devtools)
## install_github("kimbridges/sitemaps") ## Do this just once
library(sitemaps)
## Use two functions from sitemaps to initialize parameters
column <- site_styles()
hide <- site_google_hides()
column$margin = 2.0
## Register the Google Maps Key
googleKey <- Sys.getenv("GGMAP_GOOGLE_API_KEY")
register_google(key = googleKey, account_type = "standard")
## Establish a theme that improves the appearance of a map.
## This theme removes the axis labels and
## puts a border around the map. No legend.
simple_black_box <- theme_void() +
theme(panel.border = element_rect(
color = "black",
fill = NA,
linewidth = 2),
legend.position = "none")
## Load the data
data <- read.csv("Pump_Data_Table.csv")
## Rename the ID field to text
data <- data |>
dplyr::rename(text = ID) |>
dplyr::rename(lat = Latitude) |>
dplyr::rename(lon = Longitude)
gt(data) |>
## Title on the table
tab_caption(caption = "CSV Input Example") |>
## Source Information
tab_source_note(
source_note = "Source: Pump_Data_Table.csv") |>
tab_footnote(
footnote = "Likely a bad conversion to latitude, longitude",
locations = cells_column_labels(columns=c(lon, lat)))| text | Name | Address | lon1 | lat1 |
|---|---|---|---|---|
| 1 | Oxford Market | Oxford Market | 6.98502 | 57.11404 |
| 6 | Little Marborough St. | Little Marblborough St. | 6.98497 | 57.11042 |
| 2 | Hanover Square | Hanover Sq | 6.98239 | 57.11044 |
| 4 | Berners St. | Berner's St. | 6.98777 | 57.11340 |
| 5 | Newman St. | Newman St. | 6.98863 | 57.11366 |
| 7 | Broad St. | Broad St. | 6.98707 | 57.10973 |
| 3 | Castle St. E. | Castle St. E. | 6.98612 | 57.11405 |
| 12 | Picadilly Circus | Tichbone St. | 6.98894 | 57.10546 |
| 8 | Bridle St. | Bridle St. | 6.98764 | 57.10733 |
| 9 | Rupert St. | Rupert St. | 6.98928 | 57.10816 |
| 10 | Warwick St. | Warwick St. | 6.98600 | 57.10702 |
| 11 | Dean St. | King St. | 6.99074 | 57.10846 |
| 14 | Vigo St. | Vigo St. | 6.98498 | 57.10538 |
| 13 | Marlborough Mews | Marlborough Mews | 6.98500 | 57.11181 |
| 0 | Oxford St. Smithy | 365 Oxford St. | 6.98497 | 57.11234 |
| 1 Likely a bad conversion to latitude, longitude | ||||
| Source: Pump_Data_Table.csv | ||||
## Create the base map
basemap <- site_google_basemap(datatable = data)
## Plot the data points on the map
ggmap(basemap) +
site_points(datatable = data) +
site_labels(datatable = data) +
theme_minimal()