How to Use Mapboxes in Shiny While Offline

I’ve got an open stack overflow thread for this question here.

I’m developing a shiny app which will just be launched from a stand-alone computer.

One of my tabs has a map, which I’m overlaying lines on. The number of lines can be dynamic, and sometimes they overlap so much that I need to suppress some of them. Since I’ve been using ggplot, I’ve been getting around this by having a dynamically sized checkbox group, with one item per map line.

I want to switch to plotly mapboxes so that I can have all the useful built in features such as pan, zoom, and most importantly, line suppression. The problem is, I need to be able to use this offline.

With my current setup, I have a tile set that I downloaded with ggmap and saved as an RDS. While offline, I can read in the RDS data, plot it with ggplot, construct my map lines as SF objects, and overlay them with geom_sf. But how can I use mapboxes offline?

I’ve read a little bit about using a locally hosted tile server, but I’m not sure how to do that, and most of the posts that I’ve found, or which people have shared with me are for Python.

I think my answer might be using the mapbox layers, and setting the source to my locally saved tile set, but not the RDS version of it. Or perhaps that needs to point to a locally hosted offline tileserver? I’m not quite sure, and my attempts at it have failed.

Has anybody done something like this before? Thanks!

So, I didn’t derive the solution I was expecting, but I did come up with something functional.

I was able to take the locally downloaded tileset, plot it with ggmap and geom_sf for my lines, and just feed that into a ggplotly and renderPlotly. This is similar enough to what I was hoping to achieve that I’m not going to continue pursuing mapboxes.