Description Usage Arguments Examples
If you want to create and serve your own vector tiles you may check t-rex.
1 2 | add_vector_tiles(ol, url, attribution = NULL, style = NULL,
options = layer_options(), format = NULL)
|
ol |
map widget |
url |
url of the vector tiles service |
attribution |
attribution |
style |
style object or |
options |
general layer options, see |
format |
format of the vector tiles, |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ## Not run:
# mapzen
key <- "your_api_key"
mapzen <- paste0(
"https://tile.mapzen.com/mapzen/vector/v1/",
"roads/{z}/{x}/{y}.topojson",
"?api_key=", key
)
ol() %>%
add_vector_tiles(mapzen, "Add mapzen attribution") %>%
set_view(zoom = 16)
# mapbox
key <- "your_access_token"
mapbox <- paste0(
"https://{a-d}.tiles.mapbox.com/v4/",
"mapbox.mapbox-streets-v7/",
"{z}/{x}/{y}.vector.pbf",
"?access_token=", key
)
attribution <- "Add mapbox attribution"
ol() %>%
add_vector_tiles(mapbox, attribution)
# style the tiles
ol() %>%
add_vector_tiles(
mapbox,
attribution,
style = stroke_style(color = "green") + fill_style()
) %>%
set_view(zoom = 14)
# use javascript style function
mapbox_style <- system.file("javascript/mvt_style_function.js", package = "openlayers") %>%
read_js_function()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.