From 20135e87900d4c0cb60744f59f342f0ac9cc3a09 Mon Sep 17 00:00:00 2001 From: Daniel Vartanian Date: Sun, 5 Apr 2026 02:07:23 -0300 Subject: [PATCH 1/2] Fix #192 --- R/screenshot.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/R/screenshot.R b/R/screenshot.R index 61e0a9e..705dd16 100644 --- a/R/screenshot.R +++ b/R/screenshot.R @@ -9,8 +9,10 @@ #' @param filename Character string. The output file path. Defaults to #' `"map.png"`. If the filename does not end in `.png`, the extension is #' appended automatically. -#' @param width Integer. The width of the map viewport in pixels. -#' @param height Integer. The height of the map viewport in pixels. +#' @param width Integer. The width of the map viewport in pixels. Always +#' overrides any `width` configured when the map widget was created. +#' @param height Integer. The height of the map viewport in pixels. Always +#' overrides any `height` configured when the map widget was created. #' @param include_legend Logical. Include the legend in the output? Default #' `TRUE`. #' @param hide_controls Logical. Hide navigation and other interactive controls? @@ -86,6 +88,10 @@ save_map <- function( } map$x$additional_params$preserveDrawingBuffer <- TRUE + # Always override widget dimensions used by saveWidget() + map$width <- as.integer(width) |> paste0("px") + map$height <- as.integer(height) |> paste0("px") + # Save widget to temp directory tmp_dir <- tempfile("mapgl_") dir.create(tmp_dir) From 3760f3202dabf7d912ce34cde873d5ee399662e6 Mon Sep 17 00:00:00 2001 From: Daniel Vartanian Date: Sun, 5 Apr 2026 02:14:05 -0300 Subject: [PATCH 2/2] Update documentation --- man/print_map.Rd | 6 ++++-- man/save_map.Rd | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/man/print_map.Rd b/man/print_map.Rd index f4fd8f6..843d177 100644 --- a/man/print_map.Rd +++ b/man/print_map.Rd @@ -20,9 +20,11 @@ print_map( \arguments{ \item{map}{A map object created by \code{\link[=mapboxgl]{mapboxgl()}} or \code{\link[=maplibre]{maplibre()}}.} -\item{width}{Integer. The width of the map viewport in pixels.} +\item{width}{Integer. The width of the map viewport in pixels. Always +overrides any \code{width} configured when the map widget was created.} -\item{height}{Integer. The height of the map viewport in pixels.} +\item{height}{Integer. The height of the map viewport in pixels. Always +overrides any \code{height} configured when the map widget was created.} \item{include_legend}{Logical. Include the legend in the output? Default \code{TRUE}.} diff --git a/man/save_map.Rd b/man/save_map.Rd index abb46ec..0b0d687 100644 --- a/man/save_map.Rd +++ b/man/save_map.Rd @@ -25,9 +25,11 @@ save_map( \code{"map.png"}. If the filename does not end in \code{.png}, the extension is appended automatically.} -\item{width}{Integer. The width of the map viewport in pixels.} +\item{width}{Integer. The width of the map viewport in pixels. Always +overrides any \code{width} configured when the map widget was created.} -\item{height}{Integer. The height of the map viewport in pixels.} +\item{height}{Integer. The height of the map viewport in pixels. Always +overrides any \code{height} configured when the map widget was created.} \item{include_legend}{Logical. Include the legend in the output? Default \code{TRUE}.}