l_layer.map {loon} | R Documentation |
Add a Map of class map as Drawings to Loon plot
Description
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.
Usage
## S3 method for class '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 |
color |
fill color, if empty string |
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 |
index |
position among its siblings. valid values are 0, 1, 2, ..., 'end' |
asSingleLayer |
if |
... |
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']
}
}