#' Modified ggmap::ggmap() function
#'
#' The extent is default to "normal" and the xlim and ylim are set in `coord_map()` so
#' they will not delete data outside the limits in added ggplot layers. All others are the
#' same as ggmap::ggmap().
#'
#'
#' @param ggmap an object of class ggmap (from function get_map)
#' @param extent how much of the plot should the map take up?
#' "normal" (default), "device", or "panel"
#' @param base_layer a ggplot(aes(...), ...) call. The same as in the original ggmap().
#' @param maprange logical for use with base_layer; should the map
#' define the x and y limits? The same as in the original ggmap().
#' @param legend "left", "right" (default), "bottom", "top",
#' "bottomleft", "bottomright", "topleft", "topright", "none"
#' (used with extent = "device"). The same as in the original ggmap().
#' @param padding distance from legend to corner of the plot (used
#' with legend, formerly b). The same as in the original ggmap().
#' @param darken vector of the form c(number, color), where number
#' is in [0, 1] and color is a character string indicating the
#' color of the darken. 0 indicates no darkening, 1 indicates a
#' black-out. The same as in the original ggmap().
#' @param ... ... The same as in the original ggmap().
#'
#' @return a ggplot object
#'
#' @export
ggmap <- function(ggmap, extent = "normal", base_layer, maprange = FALSE,
legend = "right", padding = 0.02, darken = c(0, "black"), ...){
ggmap::ggmap(ggmap, extent, base_layer, maprange,
legend, padding, darken, ...) +
coord_map(projection="mercator",
xlim=c(attr(ggmap, "bb")$ll.lon, attr(ggmap, "bb")$ur.lon),
ylim=c(attr(ggmap, "bb")$ll.lat, attr(ggmap, "bb")$ur.lat))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.