rmapboxmapdeck

Custom Mapbox style not appearing


I am trying to use a custom Mapbox style as my basemap with R and the mapdeck package as shown on the mapdeck site but I can't get it to work. My data layers appear but no map appears in either the R Studio viewer or in a browser window. I have a Mapbox token and my code works when I use one of the standard Mapbox style templates. Am I overlooking something?

Here's the code I am using (on a Mac, in R Studio, private data replaced with {}):

library(mapdeck)

# load csv data ----------
# {my_data}

# load Mapbox token ----------
key <- "{my_token}"

# mapdeck process to plot the data ----------
mapdeck(token = key, style = "mapbox://styles/{my_user_name}/{my_styleID}", pitch = 70) %>% 
  add_arc(
    data = sites
    , layer_id = "arc_layer"
    , origin = c("site_lon", "site_lat")
    , destination = c("lab_lon", "lab_lat")
    , stroke_from = "site"
    , stroke_to = "lab"
  ) %>%
  add_scatterplot(
    data = labs_active
    , layer_id = "scatter"
    , lon = "lon"
    , lat = "lat"
    , radius = 120
    , fill_colour = "status"
  )

I've tried different browsers but none have made a difference.

Here are some of the browser console messages I get (in Safari):


Solution

  • What worked was creating my own Mapbox map style completely from scratch, then replacing the old style link with my new style link:

    mapdeck(token = key, style = "mapbox://styles/{my_user_name}/{my_NEW_styleID}")
    

    My original Mapbox style was a style based on one of Mapbox's built-in style templates (see my responses to @tospig in the comments). I am still not sure why that didn't work.