R/eq_map.R

Defines functions eq_map

Documented in eq_map

#' Create a Leaflet map widget for earthquakes with date
#'
#' This function takes a filtered data frame and maps the epicenters and annotates each point with a pop up window of date
#'
#' @param Data A filtered data frame
#' @param Text4Popup A string indicating the column to be displayed in pop up windows or a data frame of text created by eq_create_label()
#'
#' @return eq_map returns a Leaflet map widget for earthquakes.
#'
#' @importFrom leaflet addCircles
#' @importFrom leaflet addTiles
#' @importFrom leaflet leaflet
#' @importFrom magrittr "%>%"
#' @importFrom rlang .data
#'
#' @examples
#' \dontrun{
#' Countries <- c('USA', 'CHINA')
#' XMin <- ymd('2000-01-01')
#' readr::read_delim(system.file("extdata", "signif.txt", package = "TheCapstoneProject"), delim = '\t') %>%
#' eq_clean_data() %>%
#' dplyr::filter(COUNTRY %in% Countries) %>%
#' dplyr::filter(DATE >=  XMin) %>%
#' eq_map(Text2Popup = "DATE")
#'}
#'
#' @export
eq_map <- function(Data = rlang::.data, Text4Popup)
{
  leaflet::leaflet(Data) %>%
    leaflet::addTiles() %>%
      leaflet::addCircles(lng = ~LONGITUDE, lat = ~LATITUDE, weight = 1, radius = ~EQ_PRIMARY*1E4, popup = ~eval(parse(text = Text4Popup)))
}
ekawabata/TheCapstoneProject documentation built on June 27, 2020, 7:58 a.m.