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

Option to switch to remote version of Mapbox GL JS v2 #104

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

walkerke
Copy link

Hi @crazycapivara -

Following our discussion in #103, this PR gives users the option to switch to a remote version of Mapbox GL JS v2. (An option to download the dependencies locally can follow, but I wanted to keep this minimal). The new function is mapboxer_use_v2(), which functions similarly to sf::sf_use_s2() in that users can supply TRUE or FALSE to switch the option on or off. The new code shouldn't impact any users' existing code, but gives users the option to incorporate new features in GL JS v2 if they want to switch on the option.

This example illustrates how to use the example in vector-layer-filled-polygons.R but with a 3D globe projection, available in GL JS v2.

library(mapboxer)
mapboxer_use_v2(TRUE)

vector_src <- mapbox_source(
  type = "vector",
  url = "mapbox://mapbox.country-boundaries-v1"
)

SRC_ID <- "country-boundaries-data"

layer_style <- list(
  "id" = "country-boundaries",
  "type" = "fill",
  "source" = SRC_ID,
  "source-layer" = "country_boundaries",
  "paint" = list(
    "fill-color" = "blue",
    "fill-opacity" = 0.6
  )
)

mapboxer(
  style = basemaps$Carto$positron,
  center = c(0, 0),
  zoom = 1, 
  projection = "globe"
) %>%
  add_source(vector_src, id = SRC_ID) %>%
  add_layer(layer_style)

image

Thanks for considering the PR!

@crazycapivara
Copy link
Owner

Hi @walkerke,
I'll check it as soon as poosible.

@srgorelik
Copy link

This works great! Exactly what I needed to render a globe in R Shiny. Thanks so much @crazycapivara for this package and @walkerke for your PR! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants