Skip to content

Discussion: support for Mapbox GL JS v2 #103

@walkerke

Description

@walkerke

Hi @crazycapivara -

First of all - thanks for putting this package together. Mapbox GL JS is such a large library to interface with as an htmlwidget, I appreciate the work you've done!

I'm bringing my discussion in #101 over here. Mapbox GL JS v2 has a number of features that I think would be of interest to users, including Globe view and non-Mercator projections. You've designed the package API to accommodate those features automatically which is excellent.

The hang-up may be that Mapbox GL JS is now commercially licensed, locking users into their payment structure (see mapbox/mapbox-gl-js#10162). I'm a Mapbox customer so that doesn't bother me but I know it may be a bigger issue for some users.

I've forked mapboxer and written a small implementation that gives users the option to use v1 (which remains the default) or v2, and bundles both libraries. It works in a similar way to sf::sf_use_s2(). For example, by default users requesting the globe view will get the regular Mercator projection, because they are using v1:

library(mapboxer)

mapboxer(
  center = c(-73.9165, 40.7114),
  style = basemaps$Mapbox$streets_v11,
  zoom = 2,
  projection = "globe"
)

image

A mapboxer_use_v2() function in my fork switches the GL JS version to v2, enabling the globe feature:

mapboxer_use_v2(TRUE)

mapboxer(
  center = c(-73.9165, 40.7114),
  style = basemaps$Mapbox$streets_v11,
  zoom = 2,
  projection = "globe"
)
Using Mapbox GL JS v2.
Please review the Mapbox terms of service for version 2
at https://www.mapbox.com/legal/tos/

image

Would you be interested in a PR to support this? I'd understand if supporting two versions is too confusing for users (and I'm fine using my fork in my own projects). However, I think users might really like this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions