qfes / rdeck

Deck.gl widget for R
https://qfes.github.io/rdeck
MIT License
98 stars 0 forks source link

Support non-mapbox basemap layers #115

Open JosiahParry opened 6 months ago

JosiahParry commented 6 months ago

I've tried exploring rdeck but right way I noticed that it doesn't have any base map support with free tiers. For example openlayers or maplibre are not supported. I don't want to give my credit card to mapbox in order to create an account! 🙈

It would be great if the package supported other basemaps. https://deck.gl/docs/get-started/using-with-map

jaredlander commented 6 months ago

I know that in deck.gl in JavaScript you can skip the basemap and use a WMS (or similar) tile server output as a feature layer. This allows you to make maps without a map box token. Would be awesome if rdeck similarly allowed you to not include the basemap and exposed WMSLayer or similar.

Here's an example JavaScript map.

https://github.com/visgl/deck.gl/blob/9.0-release/examples%2Fwebsite%2Fwms%2Fapp.tsx

anthonynorth commented 6 months ago

Basemaps without a token can currently only be achieved with raster tiles, using the tile_layer.

Maplibre support is planned #119 and should be simple. WMSLayer support will come with deck.gl v9 (also planned)

jaredlander commented 6 months ago

So with V9 could we skip the basemap altogether and just use WMSLayer?

anthonynorth commented 6 months ago

Yes. The basemap doesn't render if map_style = NULL, so you can do

# no basemap
rdeck(map_style = NULL) |>
  add_whatever_layer()

Looks like disabling basemap isn't documented! :facepalm:.

Edit: no-token / invalid token "works" also, but you'll get an error in the js console.

options(rdeck.mapbox_access_token = "nope")
pts <- vctrs::data_frame(
  position = rdeck::xy(runif(1e4, -180, 180), runif(1e4, -90, 90))
)

rdeck::rdeck() |>
  rdeck::add_scatterplot_layer(data = pts, radius_min_pixels = 2)
jaredlander commented 6 months ago

That's great, thanks. I look forward to trying it when the WMS layer is released.