#' A interactive map showing earthquakes with custom annotations.
#'
#' This function is used to plot EQ data on map with radius of circle based on the primary magnitude.
#' Currently this is limited to the magnitude by code because that is what the assignment said to do.
#'
#' @param data A \code{data.frame} output from \code{eq_clean_data} or substantially similar
#' data. This is required as the radius of points and the latitude and longitude are mapped to
#' columns named "EQ_PRIMARY", "LATITUDE", "LONGITUDE" (respectively). These are defaults from
#' \code{eq_clean_data}, so when not using this function you must rename data appropriately.
#'
#' @param annot_col Column inside \code{data} that will be used to annotate the data
#'
#' @importFrom leaflet leaflet addProviderTiles addCircleMarkers
#'
#' @export
#'
#' @examples
#' \dontrun{
#'
#' EQdata %>%
#' mutate(maplabel=eq_create_label(.)) %>%
#' eq_map(annot_col=maplabel)
#'
#' }
#'
eq_map <- function(data, annot_col)
{
leaflet::leaflet() %>%
leaflet::addTiles() %>%
leaflet::addCircleMarkers(data = data,
radius = ~EQ_PRIMARY,
lng = ~LONGITUDE,
lat = ~LATITUDE,
popup = ~data[[`annot_col`]])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.