tm_basemap | R Documentation |
Creates a tmap-element
that draws a tile layer. This feature is only available in view mode. For plot mode, a tile image can be retrieved by read_osm
. The function tm_basemap
draws the tile layer as basemap (i.e. as bottom layer), whereas tm_tiles
draws the tile layer as overlay layer (where the stacking order corresponds to the order in which this layer is called). Note that basemaps are shown by default (see details).
tm_basemap(server = NA, group = NA, alpha = NA, tms = FALSE)
tm_tiles(server, group = NA, alpha = 1, zindex = NA, tms = FALSE)
server |
name of the provider or an URL. The list of available providers can be obtained with |
group |
name of the group to which this layer belongs in view mode. Each group can be selected or deselected in the layer control item. Set |
alpha |
alpha |
tms |
is the provided tile server defined according to the TMS protocol? By default |
zindex |
zindex of the pane in view mode. By default, it is set to the layer number plus 400. By default, the tmap layers will therefore be placed in the custom panes |
When tm_basemap
is not specified, the default basemaps are shown, which can be configured by the basemaps
arugument in tmap_options
. By default (for style "white"
) three basemaps are drawn: c("Esri.WorldGrayCanvas", "OpenStreetMap", "Esri.WorldTopoMap")
. To disable basemaps, add tm_basemap(NULL)
to the plot, or set tmap_options(basemaps = NULL)
. Similarly, when tm_tiles
is not specified, the overlay maps specified by the overlays
argument in in tmap_options
are shown as front layer. By default, this argument is set to NULL
, so no overlay maps are shown by default. See examples.
## Not run:
current.mode <- tmap_mode("view")
data(World, metro)
tm_basemap(leaflet::providers$Stamen.Watercolor) +
tm_shape(metro, bbox = "India") + tm_dots(col = "red", group = "Metropolitan areas") +
tm_tiles(paste0("http://services.arcgisonline.com/arcgis/rest/services/Canvas/",
"World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}"), group = "Labels")
# Use tmap options to set the basemap and overlay map permanently during the R session:
opts <- tmap_options(basemaps = c(Canvas = "Esri.WorldGrayCanvas", Imagery = "Esri.WorldImagery"),
overlays = c(Labels = paste0("http://services.arcgisonline.com/arcgis/rest/services/Canvas/",
"World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}")))
qtm(World, fill = "HPI", fill.palette = "RdYlGn")
# restore options
tmap_options(opts)
# restore current mode
tmap_mode(current.mode)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.