l_layer.map | R Documentation |
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 class 'map'
l_layer(
widget,
x,
color = "",
linecolor = "black",
linewidth = 1,
label,
parent = "root",
index = 0,
asSingleLayer = TRUE,
...
)
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 |
If asSingleLayer=TRUE
then returns layer id of polygons layer,
otherwise group layer that contains polygon children layers.
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']
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.