Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use leaflet.providers package #636

Merged
merged 17 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Imports:
scales (>= 1.0.0),
sp,
stats,
viridis (>= 0.5.1)
viridis (>= 0.5.1),
leaflet.providers (>= 1.8.0)
Suggests:
knitr,
maps,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export(popupOptions)
export(previewColors)
export(projectRasterForLeaflet)
export(providerTileOptions)
export(providers)
export(providers.details)
export(removeControl)
export(removeGeoJSON)
export(removeImage)
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
leaflet 2.0.3
--------------------------------------------------------------------------------

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

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.
* invokeRemote() now resolves html dependencies before passing them to shiny::createWebDependency() (#620).
* Upgrade leaflet-provider to 1.4.0, enable more map variants such as CartoDB.Voyager (#567)
Expand Down
2 changes: 1 addition & 1 deletion R/plugin-minimap.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ addMiniMap <- function(
tilesURL <- NULL
tilesProvider <- NULL
if (!is.null(tiles)) {
if (tiles %in% leaflet::providers) {
if (tiles %in% providers) {
map$dependencies <- c(map$dependencies, leafletProviderDependencies())
tilesProvider <- tiles
} else {
Expand Down
47 changes: 35 additions & 12 deletions R/plugin-providers.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
leafletProviderDependencies <- function() {
list(
htmltools::htmlDependency(
"leaflet-providers",
"1.1.17",
system.file("htmlwidgets/lib/leaflet-providers", package = "leaflet"),
script = "leaflet-providers.js"
),
get_providers_html_dependency(),
htmltools::htmlDependency(
"leaflet-providers-plugin",
packageVersion("leaflet"),
Expand Down Expand Up @@ -72,12 +67,40 @@ providerTileOptions <- function(errorTileUrl = "", noWrap = FALSE,
#'
#' @format A list of characters
#' @source \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
#'
#' @name providers
#' @export providers
#' @rdname providers
NULL
# Active binding added in zzz.R
"providers"

#' Providers Details
#'
#' List of all providers with their variations and additional info
#'
#' @format A list of lists (JSON)
#' @source \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
#' @name providers.details
#' @export providers.details
#' @rdname providers
NULL
# Active binding added in zzz.R
"providers.details"

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

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

get_providers_html_dependency <- function() {
tmpfile <- file.path(tempdir(), paste0("leaflet-providers_", providers.version_num, ".js"))

if (!file.exists(tmpfile)) {
src <- providers.src
writeLines(src, tmpfile)
}

htmltools::htmlDependency(
"leaflet-providers",
providers.version_num,
src = dirname(tmpfile),
script = basename(tmpfile),
all_files = FALSE
)
}
18 changes: 18 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
leaflet_envir <- environment()
.onLoad <- function(...) {
makeActiveBinding("providers", function() {
leaflet.providers::providers_loaded()$providers
}, env = leaflet_envir)

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

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

makeActiveBinding("providers.src", function() {
leaflet.providers::providers_loaded()$src
}, env = leaflet_envir)
}
24 changes: 0 additions & 24 deletions data-raw/providerNames.R

This file was deleted.

Binary file removed data/providers.details.rda
Binary file not shown.
Binary file removed data/providers.rda
Binary file not shown.
Loading