Skip to content

Commit c8c8d9b

Browse files
committed
Pass addRasterImage options correctly
1 parent 783b32b commit c8c8d9b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

R/layers.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ addRasterImage <- function(
271271
project = project,
272272
method = method,
273273
maxBytes = maxBytes,
274+
options = options,
274275
data = data
275276
)
276277
} else if (inherits(x, "RasterLayer")) {
@@ -285,6 +286,7 @@ addRasterImage <- function(
285286
project = project,
286287
method = method,
287288
maxBytes = maxBytes,
289+
options = options,
288290
data = data
289291
)
290292
} else {
@@ -392,6 +394,7 @@ addRasterImage_RasterLayer <- function(
392394
project = TRUE,
393395
method = c("auto", "bilinear", "ngb"),
394396
maxBytes = 4 * 1024 * 1024,
397+
options = gridOptions(),
395398
data = getMapData(map)
396399
) {
397400

@@ -450,7 +453,7 @@ addRasterImage_RasterLayer <- function(
450453
list(raster::ymin(bounds), raster::xmax(bounds))
451454
)
452455

453-
invokeMethod(map, data, "addRasterImage", uri, latlng, opacity, attribution, layerId, group, options) %>%
456+
invokeMethod(map, data, "addRasterImage", uri, latlng, layerId, group, options) %>%
454457
expandLimits(
455458
c(raster::ymin(bounds), raster::ymax(bounds)),
456459
c(raster::xmin(bounds), raster::xmax(bounds))
@@ -468,6 +471,7 @@ addRasterImage_SpatRaster <- function(
468471
project = TRUE,
469472
method = c("auto", "bilinear", "ngb"),
470473
maxBytes = 4 * 1024 * 1024,
474+
options = gridOptions(),
471475
data = getMapData(map)
472476
) {
473477
if (!is_installed("terra", "1.6-3")) { # for terra::has.RGB()
@@ -477,6 +481,9 @@ addRasterImage_SpatRaster <- function(
477481
)
478482
}
479483

484+
options$opacity <- opacity
485+
options$attribution <- attribution
486+
480487
if (terra::has.RGB(x)) {
481488
# RGB(A) channels to color table
482489
x <- terra::colorize(x, "col")
@@ -554,7 +561,7 @@ addRasterImage_SpatRaster <- function(
554561
list(terra::ymin(bounds), terra::xmax(bounds))
555562
)
556563

557-
invokeMethod(map, data, "addRasterImage", uri, latlng, opacity, attribution, layerId, group) %>%
564+
invokeMethod(map, data, "addRasterImage", uri, latlng, layerId, group, options) %>%
558565
expandLimits(
559566
c(terra::ymin(bounds), terra::ymax(bounds)),
560567
c(terra::xmin(bounds), terra::xmax(bounds))

inst/htmlwidgets/assets/leaflet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ methods.setGroupOptions = function (group, options) {
22662266
this.showHideGroupsOnZoom();
22672267
};
22682268

2269-
methods.addRasterImage = function (uri, bounds, opacity, attribution, layerId, group, options) {
2269+
methods.addRasterImage = function (uri, bounds, layerId, group, options) {
22702270
// uri is a data URI containing an image. We want to paint this image as a
22712271
// layer at (top-left) bounds[0] to (bottom-right) bounds[1].
22722272
// We can't simply use ImageOverlay, as it uses bilinear scaling which looks

javascript/src/methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ methods.setGroupOptions = function(group, options) {
983983
this.showHideGroupsOnZoom();
984984
};
985985

986-
methods.addRasterImage = function(uri, bounds, opacity, attribution, layerId, group, options) {
986+
methods.addRasterImage = function(uri, bounds, layerId, group, options) {
987987
// uri is a data URI containing an image. We want to paint this image as a
988988
// layer at (top-left) bounds[0] to (bottom-right) bounds[1].
989989

0 commit comments

Comments
 (0)