Skip to content

Commit bc7b4d2

Browse files
authored
feat: Use stable leaflet.providers html dep if available (#884)
1 parent 1c06a65 commit bc7b4d2

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Imports:
5454
htmltools,
5555
htmlwidgets (>= 1.5.4),
5656
jquerylib,
57-
leaflet.providers (>= 1.8.0),
57+
leaflet.providers (>= 1.13.0.9001),
5858
magrittr,
5959
methods,
6060
png,
@@ -79,4 +79,6 @@ Suggests:
7979
Config/testthat/edition: 3
8080
Encoding: UTF-8
8181
LazyData: true
82+
Remotes:
83+
rstudio/leaflet.providers
8284
RoxygenNote: 7.2.3

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# leaflet (development version)
22

3+
* 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).
4+
35
# leaflet 2.2.0
46

57
### Features

R/plugin-providers.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,19 @@ NULL
8989
# Active binding added in zzz.R
9090
"providers.src"
9191

92+
# Active binding added in zzz.R
93+
"providers.dep"
94+
9295
get_providers_html_dependency <- function() {
96+
if (is.null(providers.dep)) {
97+
return(create_temp_providers_html_dependency())
98+
}
99+
100+
providers.dep
101+
}
102+
103+
create_temp_providers_html_dependency <- function() {
104+
# for compatibility with older versions of leaflet.providers
93105
tmpfile <- file.path(tempdir(), paste0("leaflet-providers_", providers.version_num, ".js"))
94106

95107
if (!file.exists(tmpfile)) {

R/zzz.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ leaflet_envir <- environment()
1515
makeActiveBinding("providers.src", function() {
1616
leaflet.providers::providers_loaded()$src
1717
}, env = leaflet_envir)
18+
19+
makeActiveBinding("providers.dep", function() {
20+
leaflet.providers::providers_loaded()$dep
21+
}, env = leaflet_envir)
1822
}

0 commit comments

Comments
 (0)