Skip to content

Commit

Permalink
feat: Use stable leaflet.providers html dep if available
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Oct 5, 2023
1 parent 1c06a65 commit 4953df7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/plugin-providers.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ NULL
# Active binding added in zzz.R
"providers.src"

# Active binding added in zzz.R
"providers.dep"

get_providers_html_dependency <- function() {
if (is.null(providers.dep)) {
return(create_temp_providers_html_dependency())
}

providers.dep
}

create_temp_providers_html_dependency <- function() {
# for compatibility with older versions of leaflet.providers
tmpfile <- file.path(tempdir(), paste0("leaflet-providers_", providers.version_num, ".js"))

if (!file.exists(tmpfile)) {
Expand Down
4 changes: 4 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ leaflet_envir <- environment()
makeActiveBinding("providers.src", function() {
leaflet.providers::providers_loaded()$src
}, env = leaflet_envir)

makeActiveBinding("providers.dep", function() {
leaflet.providers::providers_loaded()$dep
}, env = leaflet_envir)
}

0 comments on commit 4953df7

Please sign in to comment.