diff --git a/R/layers.R b/R/layers.R index 508e95c06..d68a9043a 100644 --- a/R/layers.R +++ b/R/layers.R @@ -271,6 +271,7 @@ addRasterImage <- function( project = project, method = method, maxBytes = maxBytes, + options = options, data = data ) } else if (inherits(x, "RasterLayer")) { @@ -285,6 +286,7 @@ addRasterImage <- function( project = project, method = method, maxBytes = maxBytes, + options = options, data = data ) } else { @@ -392,6 +394,7 @@ addRasterImage_RasterLayer <- function( project = TRUE, method = c("auto", "bilinear", "ngb"), maxBytes = 4 * 1024 * 1024, + options = gridOptions(), data = getMapData(map) ) { @@ -450,7 +453,7 @@ addRasterImage_RasterLayer <- function( list(raster::ymin(bounds), raster::xmax(bounds)) ) - invokeMethod(map, data, "addRasterImage", uri, latlng, opacity, attribution, layerId, group, options) %>% + invokeMethod(map, data, "addRasterImage", uri, latlng, layerId, group, options) %>% expandLimits( c(raster::ymin(bounds), raster::ymax(bounds)), c(raster::xmin(bounds), raster::xmax(bounds)) @@ -468,6 +471,7 @@ addRasterImage_SpatRaster <- function( project = TRUE, method = c("auto", "bilinear", "ngb"), maxBytes = 4 * 1024 * 1024, + options = gridOptions(), data = getMapData(map) ) { if (!is_installed("terra", "1.6-3")) { # for terra::has.RGB() @@ -477,6 +481,9 @@ addRasterImage_SpatRaster <- function( ) } + options$opacity <- opacity + options$attribution <- attribution + if (terra::has.RGB(x)) { # RGB(A) channels to color table x <- terra::colorize(x, "col") @@ -554,7 +561,7 @@ addRasterImage_SpatRaster <- function( list(terra::ymin(bounds), terra::xmax(bounds)) ) - invokeMethod(map, data, "addRasterImage", uri, latlng, opacity, attribution, layerId, group) %>% + invokeMethod(map, data, "addRasterImage", uri, latlng, layerId, group, options) %>% expandLimits( c(terra::ymin(bounds), terra::ymax(bounds)), c(terra::xmin(bounds), terra::xmax(bounds)) diff --git a/inst/htmlwidgets/assets/leaflet.js b/inst/htmlwidgets/assets/leaflet.js index 43afdb9e6..79dbe714a 100644 --- a/inst/htmlwidgets/assets/leaflet.js +++ b/inst/htmlwidgets/assets/leaflet.js @@ -2266,7 +2266,7 @@ methods.setGroupOptions = function (group, options) { this.showHideGroupsOnZoom(); }; -methods.addRasterImage = function (uri, bounds, opacity, attribution, layerId, group, options) { +methods.addRasterImage = function (uri, bounds, layerId, group, options) { // uri is a data URI containing an image. We want to paint this image as a // layer at (top-left) bounds[0] to (bottom-right) bounds[1]. // We can't simply use ImageOverlay, as it uses bilinear scaling which looks diff --git a/javascript/src/methods.js b/javascript/src/methods.js index d2d3a1e1a..91d8ea70b 100644 --- a/javascript/src/methods.js +++ b/javascript/src/methods.js @@ -983,7 +983,7 @@ methods.setGroupOptions = function(group, options) { this.showHideGroupsOnZoom(); }; -methods.addRasterImage = function(uri, bounds, opacity, attribution, layerId, group, options) { +methods.addRasterImage = function(uri, bounds, layerId, group, options) { // uri is a data URI containing an image. We want to paint this image as a // layer at (top-left) bounds[0] to (bottom-right) bounds[1].