Skip to content

Commit

Permalink
Merged origin/main into johnbaums-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Oct 19, 2023
2 parents 9c57722 + bc7b4d2 commit a1cbcda
Show file tree
Hide file tree
Showing 46 changed files with 21,533 additions and 34,986 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
^cran-comments\.md$
^revdep$
^\.github$
^CRAN-SUBMISSION$
98 changes: 58 additions & 40 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,66 +1,84 @@
Package: leaflet
Type: Package
Package: leaflet
Title: Create Interactive Web Maps with the JavaScript 'Leaflet' Library
Version: 2.1.2.9000
Version: 2.2.0.9000
Authors@R: c(
person("Joe", "Cheng", email = "[email protected]", role = c("aut", "cre")),
person("Barret", "Schloerke", role = c("aut")),
person("Bhaskar", "Karambelkar", role = c("aut")),
person("Yihui", "Xie", role = c("aut")),
person("Hadley", "Wickham", role = c("ctb")),
person("Kenton", "Russell", role = c("ctb")),
person("Kent", "Johnson", role = c("ctb")),
person("Vladimir", "Agafonkin", role = c("ctb", "cph"), comment = "Leaflet library"),
person("CloudMade", role = c("cph"), comment = "Leaflet library"),
person("Leaflet contributors", role = c("ctb"), comment = "Leaflet library"),
person("Brandon Copeland", role = c("ctb", "cph"), comment = "leaflet-measure plugin"),
person("Joerg Dietrich", role = c("ctb", "cph"), comment = "Leaflet.Terminator plugin"),
person("Benjamin Becquet", role = c("ctb", "cph"), comment = "Leaflet.MagnifyingGlass plugin"),
person("Norkart AS", role = c("ctb", "cph"), comment = "Leaflet.MiniMap plugin"),
person("L. Voogdt", role = c("ctb", "cph"), comment = "Leaflet.awesome-markers plugin"),
person("Daniel Montague", role = c("ctb", "cph"), comment = "Leaflet.EasyButton plugin"),
person("Kartena AB", role = c("ctb", "cph"), comment = "Proj4Leaflet plugin"),
person("Robert Kajic", role = c("ctb", "cph"), comment = "leaflet-locationfilter plugin"),
person("Mapbox", role = c("ctb", "cph"), comment = "leaflet-omnivore plugin"),
person("Michael Bostock", role = c("ctb", "cph"), comment = "topojson"),
person("RStudio", role = c("cph"))
)
person("Joe", "Cheng", , "[email protected]", role = c("aut", "cre")),
person("Barret", "Schloerke", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0001-9986-114X")),
person("Bhaskar", "Karambelkar", role = "aut"),
person("Yihui", "Xie", role = "aut"),
person("Hadley", "Wickham", role = "ctb"),
person("Kenton", "Russell", role = "ctb"),
person("Kent", "Johnson", role = "ctb"),
person("Vladimir", "Agafonkin", role = c("ctb", "cph"),
comment = "Leaflet library"),
person("CloudMade", role = "cph",
comment = "Leaflet library"),
person("Leaflet contributors", role = "ctb",
comment = "Leaflet library"),
person("Brandon Copeland", role = c("ctb", "cph"),
comment = "leaflet-measure plugin"),
person("Joerg Dietrich", role = c("ctb", "cph"),
comment = "Leaflet.Terminator plugin"),
person("Benjamin Becquet", role = c("ctb", "cph"),
comment = "Leaflet.MagnifyingGlass plugin"),
person("Norkart AS", role = c("ctb", "cph"),
comment = "Leaflet.MiniMap plugin"),
person("L. Voogdt", role = c("ctb", "cph"),
comment = "Leaflet.awesome-markers plugin"),
person("Daniel Montague", role = c("ctb", "cph"),
comment = "Leaflet.EasyButton plugin"),
person("Kartena AB", role = c("ctb", "cph"),
comment = "Proj4Leaflet plugin"),
person("Robert Kajic", role = c("ctb", "cph"),
comment = "leaflet-locationfilter plugin"),
person("Mapbox", role = c("ctb", "cph"),
comment = "leaflet-omnivore plugin"),
person("Michael Bostock", role = c("ctb", "cph"),
comment = "topojson"),
person("Posit Software, PBC", role = c("cph", "fnd"))
)
Description: Create and customize interactive maps using the 'Leaflet'
JavaScript library and the 'htmlwidgets' package. These maps can be used
directly from the R console, from 'RStudio', in Shiny applications and R Markdown
documents.
JavaScript library and the 'htmlwidgets' package. These maps can be
used directly from the R console, from 'RStudio', in Shiny
applications and R Markdown documents.
License: GPL-3
URL: https://rstudio.github.io/leaflet/
URL: https://rstudio.github.io/leaflet/,
https://github.com/rstudio/leaflet
BugReports: https://github.com/rstudio/leaflet/issues
Depends: R (>= 3.1.0)
Depends:
R (>= 3.1.0)
Imports:
xfun,
crosstalk,
htmlwidgets (>= 1.5.4),
htmltools,
htmlwidgets (>= 1.5.4),
jquerylib,
leaflet.providers (>= 1.13.0.9001),
magrittr,
methods,
png,
RColorBrewer,
raster (>= 3.6.3),
RColorBrewer,
scales (>= 1.0.0),
sp,
stats,
viridis (>= 0.5.1),
leaflet.providers (>= 1.8.0)
xfun
Suggests:
knitr,
maps,
sf (>= 0.9-6),
shiny,
purrr,
R6,
RJSONIO,
purrr,
testthat (>= 3.0.0),
s2,
terra
RoxygenNote: 7.2.3
sf (>= 0.9-6),
shiny,
terra,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Config/testthat/edition: 3
Remotes:
rstudio/leaflet.providers
RoxygenNote: 7.2.3
66 changes: 36 additions & 30 deletions NEWS → NEWS.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,70 @@
## leaflet 2.1.2.9000
# leaflet (development version)

FEATURES
* When `addProviderTiles()` is used with `{leaflet.providers}` version 2.0.0 or later, the `leaflet-providers` HTML dependency produced can be correctly cached by knitr. When used with older versions of `{leaflet.providers}`, the HTML dependency uses temp files that break knitr's caching mechanism (thanks @qdread, @jaredlander; #884).

# leaflet 2.2.0

### Features

- Added support for SpatRaster and SpatVector objects from the terra package. (#728)

BUG FIXES and IMPROVEMENTS
- `leaflet()` now uses jQuery 3.6.0 provided via the `{jquerylib}`package. As a result of this change, the HTML dependencies for `leaflet()` are included in the `dependencies` item of the htmlwidget object it returns. (#817, #821)

- Use correct license in OpenStreetMap attribution. (#811)
## Bug fixes and improvements

- Update jQuery to utilize `{jquerylib}`. (#817)
- Use correct license in OpenStreetMap attribution. (#811)

- Use `xfun::base64_uri()` for base64 encoding instead of **markdown** and **base64enc**. (#823)

- Remove dependencies on rgdal and rgeos. (#837)

- Respect option scrollWheelZoom=FALSE. (#827)

## leaflet 2.1.2
- Fixed #866: Correctly call `terra::has.RGB()` in `addRasterImage()` for a `SpatRaster` object. (#869)

# leaflet 2.1.2

BUG FIXES and IMPROVEMENTS
## Bug fixes and improvements

- Removed S3 warnings found on R devel (#848)

## leaflet 2.1.1
# leaflet 2.1.1

BUG FIXES and IMPROVEMENTS
## Bug fixes and improvements

- The default marker icon for `addMarkers` no longer worked, due to the CDN we were relying on apparently being retired. Fixed by pointing to a new CDN. (#782)

- New behavior from tile.openstreetmap.org caused `addTiles` default tileset to break when viewed under non-https protocol on recent versions of Chrome. Fixed by always using the https protocol to connect to openstreetmap. (#786)

## leaflet 2.1.0
# leaflet 2.1.0

BUG FIXES and IMPROVEMENTS
## Bug fixes and improvements

- Enable JS function literals (wrapped in `htmlwidgets::JS()`) to be included in arguments to methods invoked on `leafletProxy` objects. (JS function literals could already be included with methods invoked on `leaflet` objects, so this change just brings `leafletProxy` to parity.) (#420)

- Add missing CSS rule to show `<img>` in right-pane and left-pane (rstudio/rmarkdown/issues#1949, #770)

- Allow for _hidden_ but not suspended leaflet maps to queue calls (such as add raster images) until they are rendered. If a new leaflet map is created, all pending calls are removed. (#771)

## leaflet 2.0.4.1
# leaflet 2.0.4.1

FEATURES
## Features

- Updated proj4.js to 2.6.2

BUG FIXES and IMPROVEMENTS
## Bug fixes and improvements

- Minor tweaks to example data and tests, required to stay on CRAN

- Fixes broken URL (#742) and updated examples to run from system files (#576) including updated .Rmd and .html docs.

## leaflet 2.0.3
# leaflet 2.0.3

BREAKING CHANGES
## Breaking changes

- `data("providers")` and `data("providers.details")` no longer exist. Please use `leaflet::providers` and `leaflet::providers.details`. (#636)

BUG FIXES and IMPROVEMENTS
## Bug fixes and improvements

- Integrated data from `leaflet.providers` package. See [leaflet.providers](https://rstudio.github.io/leaflet.providers/) for details. (#636)
- Fixed [rstudio/crosstalk#58](https://github.com/rstudio/crosstalk/issues/58), which caused Leaflet maps that used Crosstalk shared data in Shiny apps, to be redrawn at incorrect times.
Expand All @@ -67,32 +73,32 @@ BUG FIXES and IMPROVEMENTS
- `sf` objects with `names` attributes in the `st_geometry` now visualise correctly (#595)
- GeoJSON objects missing `properties` can now be displayed (#622)

## leaflet 2.0.2
# leaflet 2.0.2

BUG FIXES and IMPROVEMENTS
## Bug fixes and improvements

- Require viridis >= 0.5.1 to avoid namespace issues with viridisLite (#557)
- Fixed broken mouse events after using leaflet-search from leaflet.extras within shiny applications (#563)
- Use leaflet namespace on `providers` in `addMiniMap` to make the function accessible in other packages. Fixes [mtennekes/tmap#231](https://github.com/mtennekes/tmap/issues/231). (#568)
- Use leaflet namespace on `providers` in `addMiniMap` to make the function accessible in other packages. Fixes [r-tmap/tmap#231](https://github.com/r-tmap/tmap/issues/231). (#568)
- Require scales >= 1.0.0 to avoid exact color matching issues (#578)

## leaflet 2.0.1
# leaflet 2.0.1

FEATURES
## Features

- Added method `addMapPane` to add custom pane layers to have fine tune control over layer ordering. New feature from within leaflet.js v1.x. (#549)
- Exposed htmlwidgets sizingPolicy in leaflet() (#548)

BUG FIXES and IMPROVEMENTS
## Bug fixes and improvements

- Default marker icon locations will now use unpkg.com instead of the leaflet cdn when using https or file protocols. (#544)
- `.leaflet-map-pane` `z-index` switched to 'auto'. Allows for map panes to appear above the map if they appear later in the dom. (#537)
- Use correct Leaflet.js scale control remove method. (#547)
- Start from world view if using flyTo or flyToBounds. (#552)

## leaflet 2.0.0
# leaflet 2.0.0

BREAKING CHANGES
## Breaking changes

- Update to latest leaflet.js v1.3.1 (#453, 314616f) Please see https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html for the latest documentation

Expand All @@ -119,7 +125,7 @@ BREAKING CHANGES
- Tooltips are now displayed with default Leaflet.js styling
- In custom javascript extensions, change all `*.bindLabel()` to `*.bindTooltip()`

BUG FIXES AND FEATURES
## Bug fixes and features

- Relative protocols are used where possible when adding tiles (#526). In RStudio 1.1.x on linux and windows, a known issue of 'https://' routes fail to load, but works within browsers (rstudio/rstudio#2661).

Expand Down Expand Up @@ -161,7 +167,7 @@ BUG FIXES AND FEATURES

- Added `preferCanvas` argument to `leafletOptions()` (#521)

## leaflet 1.1.0
# leaflet 1.1.0

- Add support for sf. sf, sfc, and sfg classes are supported with POINT,
LINESTRING, MULTILINESTRING, POLYGON, and MULTIPOLYGON geometries (note
Expand Down Expand Up @@ -200,7 +206,7 @@ BUG FIXES AND FEATURES

- Added a way for the Map instance to be instantiated via a factory.

## leaflet 1.0.2
# leaflet 1.0.2

- When used with `leafletProxy`, `fitBounds` did not return its input object as
output, so magrittr chains would break after `fitBounds` was called.
Expand Down Expand Up @@ -236,10 +242,10 @@ BUG FIXES AND FEATURES
- `addScaleBar` and related functions added, for showing Leaflet's built-in
scale bar in one of the corners of the map. (PR #201. Thanks Kent Johnson!)

## leaflet 1.0.1
# leaflet 1.0.1

- Fix #242: Compatibility with htmlwidgets 0.6 (thanks byzheng).

## leaflet 1.0.0
# leaflet 1.0.0

- Initial release
46 changes: 26 additions & 20 deletions R/layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ addRasterImage <- function(
#' @param layer the layer of the raster to target
#' @param ... additional arguments to pass through to [addLegend()]
#' @seealso [addRasterImage()]
#' @examples
#' @examplesIf interactive()
#'
#' library(terra)
#'
Expand All @@ -325,11 +325,13 @@ addRasterImage <- function(
addRasterLegend <- function(map, x, layer = 1, ...) {
stopifnot(inherits(x, "SpatRaster"))
stopifnot(length(layer) == 1 && layer > 0 && layer <= terra::nlyr(x))

## might as well do this here and only once. Subsetting would otherwise have been necessary in
## color_info <- base::subset(color_info, value %in% terra::values(x))

# might as well do this here and only once. Subsetting would otherwise have
# been necessary in
# color_info <- base::subset(color_info, value %in% terra::values(x))
x <- x[[layer]]



# Retrieve the color table from the layer. If one doesn't exist, that means
# the raster was colored some other way, like using colorFactor or something,
# and the regular addLegend() is designed for those cases.
Expand All @@ -342,25 +344,24 @@ addRasterLegend <- function(map, x, layer = 1, ...) {
# Extract the colors in #RRGGBBAA format
color_info <- data.frame(
value = ct[[1]],
color = grDevices::rgb(ct$red/255, ct$green/255, ct$blue/255, ct$alpha/255)
color = grDevices::rgb(ct$red / 255, ct$green / 255, ct$blue / 255, ct$alpha / 255)
)

lvls <- terra::levels(x)[[1]]

# Drop values that aren't part of the layer
## unlike "values", "unique" is memory-safe; it does not load all values
## into memory if the raster is large. So instead of:

# color_info <- base::subset(color_info, value %in% terra::values(x))

## remove the levels to get the raw cell values
levels(x) <- NULL
color_info <- base::subset(color_info, value %in% terra::unique(x)[[1]])
# Drop values that aren't part of the layer unlike "values", "unique" is
# memory-safe; it does not load all values into memory if the raster is large.
# So instead of:
#
# color_info <- base::subset(color_info, value %in% terra::values(x))
#
# remove the levels to get the raw cell values
levels(x) <- NULL
value_in_layer <- color_info$value %in% terra::unique(x)[[1]]
color_info <- color_info[value_in_layer & !is.na(value_in_layer), ]

res <- if (is.data.frame(lvls)) {
# Use the labels from levels(x), and look up the matching colors in the
# color table

# Use the labels from levels(x), and look up the matching colors.
# The levels data frame can have varying colnames, just normalize them
colnames(lvls) <- c("value", "label")
base::merge(color_info, lvls, by.x = "value", by.y = 1)
Expand Down Expand Up @@ -463,9 +464,14 @@ addRasterImage_SpatRaster <- function(
maxBytes = 4 * 1024 * 1024,
data = getMapData(map)
) {
if (!is_installed("terra", "1.6-3")) { # for terra::has.RGB()
stop(
"`addRasterImage()` for SpatRaster objects requires {terra} 1.6-3 or higher",
call. = FALSE
)
}

# terra 1.5-50 has terra::has.RGB()
if (has.RGB(x)) {
if (terra::has.RGB(x)) {
# RGB(A) channels to color table
x <- terra::colorize(x, "col")
} else if (terra::nlyr(x) > 1) {
Expand Down
Loading

0 comments on commit a1cbcda

Please sign in to comment.