Skip to content

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

Open
walkerke wants to merge 3 commits intocrazycapivara:masterfrom
walkerke:gljs-v2
Open

Option to switch to remote version of Mapbox GL JS v2#104
walkerke wants to merge 3 commits intocrazycapivara:masterfrom
walkerke:gljs-v2

Conversation

@walkerke
Copy link
Copy Markdown

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
Copy Markdown
Owner

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

@srgorelik
Copy link
Copy Markdown

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.

3 participants