The maps library provides some map data in polygon which can be added as drawings (currently with polygons) to Loon plots. This function adds map objects with class map from the maps library as background drawings.

# S3 method for map
l_layer(
  widget,
  x,
  color = "",
  linecolor = "black",
  linewidth = 1,
  label,
  parent = "root",
  index = 0,
  asSingleLayer = TRUE,
  ...
)

Arguments

widget

widget path as a string or as an object handle

x

a map object of class map as defined in the maps R package

color

fill color, if empty string "", then the fill is transparant

linecolor

outline color

linewidth

linewidth of outline

label

label used in the layers inspector

parent

a valid Tk parent widget path. When the parent widget is specified (i.e. not NULL) then the plot widget needs to be placed using some geometry manager like tkpack or tkplace in order to be displayed. See the examples below.

index

position among its siblings. valid values are 0, 1, 2, ..., 'end'

asSingleLayer

if TRUE then all the polygons get placed in a n-dimension layer of type polygons. Otherwise, if FALSE, each polygon gets its own layer.

...

additional arguments are not used for this methiod

Value

If asSingleLayer=TRUE then returns layer id of polygons layer, otherwise group layer that contains polygon children layers.

Examples

if(interactive()){ if (requireNamespace("maps", quietly = TRUE)) { canada <- maps::map("world", "Canada", fill=TRUE, plot=FALSE) p <- l_plot() l_map <- l_layer(p, canada, asSingleLayer=TRUE, color = "cornsilk") l_map['color'] <- ifelse(grepl("lake", canada$names, TRUE), "lightblue", "cornsilk") l_scaleto_layer(p, l_map) l_map['active'] <- FALSE l_map['active'] <- TRUE l_map['tag'] } }