knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Cartovl for R makes carto-vl, an open source JavaScript library to create vector-based visualizations on top of mapbox-gl, available within R via the htmlwidgets package.
You can install the latest version of cartovl from github with:
# install.packages("devtools") devtools::install_github("crazycapivara/cartovl")
library(sf) library(geojsonio) library(cartovl) nc_geojson <- system.file("shape/nc.shp", package = "sf") %>% st_read() %>% geojson_json() viz_def <- list( "color: ramp($AREA, [midnightblue, gold])" ) map <- cartovl() %>% set_view(-79.89042, 35.23582, 6) %>% add_layer(nc_geojson, viz_def) if (interactive()) map
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.