SymbolixAU / mapdeck

R interface to Deck.gl and Mapbox

Home Page:https://symbolixau.github.io/mapdeck/articles/mapdeck.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding more than one Mapbox style layer?

jlehman01 opened this issue · comments

Is it possible to add more than one Mapbox style layer to the same mapdeck object?

I'm trying to build a mapdeck object that contains the following items in this order: 1) Mapbox basemap, 2) polygons, and 3) Mapbox layer of just streets and labels on top of the polygons.

The only way it appears possible to add a Mapbox layer is to use the style function inside of mapbox(). But I'm wondering if I'm missing something obvious.

Thanks!

commented

Mapbox layer of just streets and labels on top of the polygons.

Do you mean that this 'layer' will only cover the area of the map that also contains the polygons, and the rest of the map will be the 'base' style? If so there's not a native / simple solution, but there are a couple of ways I can think of to achieve this effect:

1. add_bitmap()

from ?add_bitmap example:

library(mapdeck)

set_token(secret::get_secret("MAPBOX"))

mapdeck(location = c(-122.3, 37.8), zoom = 10) %>%
  add_bitmap(
    image = paste0(
      'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/',
      'website/sf-districts.png')
    , bounds = c(-122.519, 37.7045, -122.355, 37.829)
  )

Screenshot 2022-11-10 at 8 06 15 am

2 Custom Mapbox Style

You can make your own custom style - https://docs.mapbox.com/api/maps/styles/ - and set that as the style argument. I'm not too familiar with this method though and whether or not you can only change the style for certain areas and not others.

Thanks for the quick reply! (and, by the way, thanks for your work on this and other packages!)

I already have mapbox styles set up. I'm essentially looking to layer them, so that I have a basemap layer with a roadway-only layer on the top of the map, with the polygons sandwiched in-between.

Here are functions in other deck gl implementations that I think would accomplish what I'm looking to do (but I prefer mapdeck and think it would be a nice feature add if not currently possible):

@jlehman01 Did you happen to find a solution for this? I too would like to get place names above the basemap and polygons.

@timathomas I never found a workaround. It is possible to do this in leaflet and tmap so I tend to use those packages when possible.

Thanks @jlehman01. Me too. I've been able to get it to work with the Mapboxapi and Mapboxer packages but still have to edit the underlying data in mapbox studio. @dcooley I too very much appreciate you and your teams work on mapdeck, it's a great package!