knitr::opts_chunk$set( collapse = TRUE, comment = "#>", out.width = "100%" ) library(leaflet) library(TargomoR)
There are a range of map tiles available through Targomo. They can be added directly to a leaflet map through the addTargomoTiles() function, which wraps around leaflet::addTiles(). Adding these also requires an API key, which is picked up as usual from your TARGOMO_API_KEY environment variable (see setTargomoVariables() for information).
The full list of available basemap styles is given by targomoMapStyles():
cat(paste0(targomoMapStyles(), collapse = "\n"))
These should be used with addTargomoTiles(), as in:
leaflet() %>% addTargomoTiles(style = "darkblue-nolabels", api_key = ...)
To see each basemap, change the layer visible on the map below:
l <- leaflet() for (style in targomoMapStyles()) { l <- l %>% addTargomoTiles(style = style, group = style) } l %>% addLayersControl(baseGroups = targomoMapStyles(), position = "topright", options = layersControlOptions(collapsed = FALSE)) %>% setView(lat = 51.5, lng = -0.1, zoom = 14)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.