topojson_layer: TopoJSON layer

View source: R/topojson_layer.R

topojson_layerR Documentation

TopoJSON layer

Description

Add a TopoJSON layer to a d3-carto-map.

Usage

topojson_layer(carto, data, file = NULL, feature, label = "TopoJSON",
  clickable = FALSE, fill = "lightblue", stroke = "black",
  opacity = 0.5, visible = TRUE)

Arguments

carto

The map created by cartographer().

data

A TopoJSON string (unparsed). The topojson can be provided through the file parameter instead.

file

The path to a topojson file.

feature

The name of the feature object to be mapped.

label

The label for this layer on the layer selector.

clickable

Controls whether a point can be clicked to show the properties in the data frame.

fill

The fill color of the TopoJSON polygons, either as a name recognized by a browser or as a hexadecimal string (e.g., #4527f3).

stroke

The stroke color of the TopoJSON polygons.

opacity

The opacity of the TopoJSON polygons.

visible

Should the layer be initially visible?

Examples

# Path to a sample TopoJSON file
us1853 <- system.file("extdata", "us1853.topojson", package = "cartographer")
cartographer(region = "United States") %>%
  topojson_layer(file = us1853, feature = "us", label = "US 1853")

ropensci/cartographer documentation built on May 18, 2022, 9:49 a.m.