Skip to content

Commit 596d8e2

Browse files
committed
create html_dependency here, restore https handling
1 parent 7b4f318 commit 596d8e2

File tree

7 files changed

+37
-56
lines changed

7 files changed

+37
-56
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ export(projectRasterForLeaflet)
140140
export(providerTileOptions)
141141
export(providers)
142142
export(providers.details)
143-
export(providers.version_num)
144143
export(removeControl)
145144
export(removeGeoJSON)
146145
export(removeImage)

NEWS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ leaflet 2.0.3
33

44
BUG FIXES and IMPROVEMENTS
55
* Integrated data from `leaflet.providers` package; this breaks `data("providers")` and `data("providers.details")`. See [leaflet.providers](https://leslie-huang.github.io/leaflet.providers/). (#636)
6-
* Removed handling of http/https protocols for RStudio v1.1. Please update to RStudio>=v1.2 if you have missing tiles. Fixes #527. (#636)
76
* 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.
87
* invokeRemote() now resolves html dependencies before passing them to shiny::createWebDependency() (#620).
98
* Upgrade leaflet-provider to 1.4.0, enable more map variants such as CartoDB.Voyager (#567)

R/plugin-providers.R

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,49 @@ providerTileOptions <- function(errorTileUrl = "", noWrap = FALSE,
6969
#' @source \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
7070
#'
7171
#' @export
72+
#' @rdname providers
7273
providers <- NULL
7374
get_providers <- function() {
74-
getOption("leaflet.providers", default = providers)
75+
get_leaflet_providers_options("leaflet_providers", default = providers)
7576
}
7677

77-
#' Providers Details
78-
#'
79-
#' List of all providers with their variations and additional info
80-
#'
81-
#' @format A list of lists (JSON)
82-
#' @source \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
83-
#'
8478
#' @export
79+
#' @rdname providers
8580
providers.details <- NULL
8681
get_providers_details <- function() {
87-
getOption("leaflet.providers.details", default = providers.details)
82+
get_leaflet_providers_options("providers_details", default = providers.details)
8883
}
8984

90-
#' Providers version number
91-
#'
92-
#' Version number of the providers data.
93-
#'
94-
#' @format character
95-
#' @source \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
96-
#'
97-
#' @export
9885
providers.version_num <- NULL
9986

100-
providers.html_dependency <- NULL
87+
get_providers_version_num <- function() {
88+
get_leaflet_providers_options("version_num", default = providers.version_num)
89+
}
90+
91+
providers.src <- NULL
92+
10193
get_providers_html_dependency <- function() {
102-
getOption("leaflet.providers.html_dependency", default = providers.html_dependency)
94+
tmpfile <- file.path(tempdir(), paste0("leaflet-providers_", get_providers_version_num(), ".js"))
95+
96+
if (!file.exists(tmpfile)) {
97+
src <- get_leaflet_providers_options("src", default = providers.src)
98+
writeLines(src, tmpfile)
99+
}
100+
101+
html_dependency <- htmltools::htmlDependency(
102+
"leaflet-providers",
103+
get_providers_version_num(),
104+
src = tmpfile
105+
)
106+
}
107+
108+
get_leaflet_providers_options <- function(key, default) {
109+
info <- getOption("leaflet.providers")
110+
if (!is.null(info)) {
111+
val <- info[[key]]
112+
if (!is.null(val)) {
113+
return(val)
114+
}
115+
}
116+
return(default)
103117
}

R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
providers <<- providers_info$providers
55
providers.details <<- providers_info$providers_details
66
providers.version_num <<- providers_info$version_num
7-
providers.html_dependency <<- providers_info$html_dependency
7+
providers.src <<- providers_info$src
88
}

man/providers.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/providers.details.Rd

Lines changed: 0 additions & 17 deletions
This file was deleted.

man/providers.version_num.Rd

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)