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

feat: check tile providers in addProviderTiles() #929

Merged
merged 11 commits into from
Aug 7, 2024

Conversation

jack-davison
Copy link
Contributor

@jack-davison jack-davison commented Aug 2, 2024

Fixes #921
Fixes #677

In short, it adds the .check arg to addProviderTiles(), which defaults to TRUE. When TRUE, if a user mistakenly provides a provider not in leaflet.providers::providers_loaded(), the function will error.

Also adds a test to check this new argument is working as it should.

PR task list:

  • Update NEWS
  • Add tests (where appropriate)
    • R code tests: tests/testthat/
    • Visual tests: R/zzz_viztest.R
  • Update documentation with devtools::document()

@jack-davison
Copy link
Contributor Author

@schloerke, you gave this example in #921 (comment)_

addProviderTiles <- function(
  map,
  provider,
  layerId = NULL,
  group = NULL,
  options = providerTileOptions(),
  ...,
  check = TRUE
) {
  if (isTRUE(check)) {
    check_provider(provider)
  }
  map$dependencies <- c(map$dependencies, leafletProviderDependencies())
  invokeMethod(map, getMapData(map), "addProviderTiles",
    provider, layerId, group, options)
}

addProviderTiles() didn't originally have a ... param - I've added it as per your example, but it currently doesn't do anything! Did you want it adding for some reason, or was it just a mistake in your suggestion?

R/plugin-providers.R Outdated Show resolved Hide resolved
jack-davison and others added 2 commits August 4, 2024 12:31
Avoids partial matching and overlong error messages

Co-authored-by: Joe Cheng <[email protected]>
R/plugin-providers.R Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
@schloerke
Copy link
Contributor

Thank you, @jack-davison !

@schloerke schloerke merged commit 9bf137b into rstudio:main Aug 7, 2024
11 checks passed
@jack-davison jack-davison deleted the feat/check-providers branch August 7, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants