################################################################################
#
#'
#' Create Leaflet marker popup content
#'
#' Given point location data, this function facilitates the creation of
#' corresponding vector of character values to show in the popup for Leaflet
#' markers.
#'
#' @param df A data.frame containing information corresponding to each mapped
#' point location.
#'
#' @return A vector of character values with length equal to the number of
#' mapped point locations
#'
#' @examples
#' create_popup_content(df = diamagueneLocations)
#'
#' @export
#'
#
################################################################################
create_popup_content <- function(df) {
##
infraType <- paste("<b>Type:</b> ", stringr::str_to_sentence(df$infra), sep = "")
schoolType <- paste("<b>School type:</b> ", stringr::str_to_sentence(df$school_type), sep = "")
desc <- paste("<b>Description:</b> ", df$description, sep = "")
## Add text
tooltip <- vector(mode = "character", length = nrow(df))
tooltip[df$infra == "ecole"] <- paste(infraType, schoolType, desc, sep = "<br/>")[df$infra == "ecole"]
tooltip[df$infra != "ecole"] <- paste(infraType, desc, sep = "<br/>")[df$infra != "ecole"]
## Add figure
tooltip <- paste("<img src='images/",
stringr::str_remove(string = df$png, pattern = ".png"),
"_tn.jpg' align='center' /> <br/>", tooltip, sep = "")
## Return tooltip vector
return(tooltip)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.