3

I would like to make a leaflet map with a white background -- that is with either no tiles at all and with a white background, or with tiles that are all white.

Here's the leaflet "hello world":

library(leaflet)

leaflet() %>%
  addTiles() %>%
  addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")

Leaving out the addTiles() gives me a grey instead of a white background and none of the tiles in the gallery are all white.

RoyalTS
  • 9,545
  • 12
  • 60
  • 101
  • As far as I can tell, the grey background is the underlying default of the `leaflet` package. `leaflet` is meant to be used with maps (what leaflet calls tiles). I imagine you could create a custom white tile if you wanted to, but the tile has to be georectified to map coordinates to it, so unless you have a particular reason you need to use `leaflet`, you might try using a different charting package. – Mako212 Aug 31 '17 at 21:45
  • There are several ways using Leaflet package. For example, in indoor projects default background can be displayed. @RoyalTS check [this question](https://stackoverflow.com/questions/13851888/how-can-i-change-the-default-loading-tile-color-in-leafletjs) for a posible solution. – JoSerra Sep 01 '17 at 04:46

1 Answers1

5

Thanks to @JoSerra for the pointer, here's how to achieve this in the context of an RMarkdown document. Just add the following to the doc:

```{r results="asis"}
cat("
<style>
.leaflet-container {
    background: #FFF;
}
</style>
")
```
RoyalTS
  • 9,545
  • 12
  • 60
  • 101