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

Adding more than one Mapbox style layer? #360

Open
jlehman01 opened this issue Nov 9, 2022 · 5 comments
Open

Adding more than one Mapbox style layer? #360

jlehman01 opened this issue Nov 9, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@jlehman01
Copy link

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!

@jlehman01 jlehman01 added the question Further information is requested label Nov 9, 2022
@dcooley
Copy link
Collaborator

dcooley commented Nov 9, 2022

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.

@jlehman01
Copy link
Author

jlehman01 commented Nov 10, 2022

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):

@timathomas
Copy link

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

@jlehman01
Copy link
Author

@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.

@timathomas
Copy link

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!

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

No branches or pull requests

3 participants