l_layer.map.Rd
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, ...)
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 | parent widget path |
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 (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'] }#> [1] "Canada:Sable Island" #> [2] "Canada:5" #> [3] "Canada:Grand Manan Island" #> [4] "Canada:9" #> [5] "Canada:10" #> [6] "Canada:11" #> [7] "Canada:15" #> [8] "Canada:Cape Breton Island" #> [9] "Canada:Prince Edward Island" #> [10] "Canada:Ile du Cap aux Meule" #> [11] "Canada:Merasheen Island" #> [12] "Canada:Ile Lameque" #> [13] "Canada:22" #> [14] "Canada:Saltspring Island" #> [15] "Canada:Galiano Island" #> [16] "Canada:27" #> [17] "Canada:Flores Island" #> [18] "Canada:New World Island" #> [19] "Canada:Fogo Island" #> [20] "Canada:Texada Island" #> [21] "Canada:Nootka Island" #> [22] "Canada:Anticosti Island" #> [23] "Canada:Redonda Island" #> [24] "Canada:Quadra Island" #> [25] "Canada:Bell Island" #> [26] "Canada:Vancouver Island" #> [27] "Canada:Newfoundland" #> [28] "Canada:Calvert Island" #> [29] "Canada:40" #> [30] "Canada:Charlton Island" #> [31] "Canada:42" #> [32] "Canada:43" #> [33] "Canada:Aristazabal Island" #> [34] "Canada:45" #> [35] "Canada:46" #> [36] "Canada:Moresby Island" #> [37] "Canada:Princess Royal Island" #> [38] "Canada:49" #> [39] "Canada:50" #> [40] "Canada:BC:Banks Island" #> [41] "Canada:Porcher Island" #> [42] "Canada:Graham Island" #> [43] "Canada:54" #> [44] "Canada:55" #> [45] "Canada:56" #> [46] "Canada:Tukarak Island" #> [47] "Canada:58" #> [48] "Canada:Belcher Island" #> [49] "Canada:60" #> [50] "Canada:61" #> [51] "Canada:62" #> [52] "Canada:63" #> [53] "Canada:64" #> [54] "Canada:65" #> [55] "Canada:66" #> [56] "Canada:67" #> [57] "Canada:Akpatok Island" #> [58] "Canada:Smith Island" #> [59] "Canada:Resolution Island" #> [60] "Canada:71" #> [61] "Canada:Edgell Island" #> [62] "Canada:Mansel Island" #> [63] "Canada:Loks Land Island" #> [64] "Canada:Charles Island" #> [65] "Canada:Big Island" #> [66] "Canada:Coats Island" #> [67] "Canada:Nottingham Island" #> [68] "Canada:Salisbury Island" #> [69] "Canada:Mill Island" #> [70] "Canada:Southampton Island" #> [71] "Canada:White Island" #> [72] "Canada:Vansittart Island" #> [73] "Canada:Winter Island" #> [74] "Canada:85" #> [75] "Canada:86" #> [76] "Canada:87" #> [77] "Canada:Chapman Lewes Island:South" #> [78] "Canada:Air Force Island" #> [79] "Canada:90" #> [80] "Canada:Wales Island" #> [81] "Canada:Prince Charles Island" #> [82] "Canada:93" #> [83] "Canada:Melbourne Island" #> [84] "Canada:Foley Island" #> [85] "Canada:Jenny Lind Island" #> [86] "Canada:Royal Geographical Society Island:West" #> [87] "Canada:Royal Geographical Society Island:East" #> [88] "Canada:99" #> [89] "Canada:100" #> [90] "Canada:Harrison Island" #> [91] "Canada:Bray Island" #> [92] "Canada:103" #> [93] "Canada:Matty Island" #> [94] "Canada:Herschel Island" #> [95] "Canada:106" #> [96] "Canada:Koch Island" #> [97] "Canada:Jens Munk Island" #> [98] "Canada:King William Island" #> [99] "Canada:110" #> [100] "Canada:Gateshead Island" #> [101] "Canada" #> [102] "Canada:Prescott Island" #> [103] "Canada:Victoria Island" #> [104] "Canada:Stefansson Island" #> [105] "Canada:Bylot Island" #> [106] "Canada:Baffin Island" #> [107] "Canada:Prince of Wales Island" #> [108] "Canada:Russell Island" #> [109] "Canada:Somerset Island" #> [110] "Canada:Banks Island" #> [111] "Canada:122" #> [112] "Canada:123" #> [113] "Canada:Byam Martin Island" #> [114] "Canada:Cornwallis Island" #> [115] "Canada:126" #> [116] "Canada:127" #> [117] "Canada:128" #> [118] "Canada:Eglinton Island" #> [119] "Canada:Coburg Island" #> [120] "Canada:131" #> [121] "Canada:Cameron Island" #> [122] "Canada:Bathurst Island" #> [123] "Canada:Helena Island" #> [124] "Canada:Melville Island" #> [125] "Canada:North Kent Island" #> [126] "Canada:Emerald Isle" #> [127] "Canada:Devon Island" #> [128] "Canada:Prince Patrick Island" #> [129] "Canada:140" #> [130] "Canada:Lougheed Island" #> [131] "Canada:Cornwall Island" #> [132] "Canada:King Christian Island" #> [133] "Canada:Brock Island" #> [134] "Canada:Mackenzie King Island" #> [135] "Canada:146" #> [136] "Canada:Borden Island" #> [137] "Canada:Amund Ringnes Island" #> [138] "Canada:Ellef Ringnes Island" #> [139] "Canada:Meighen Island" #> [140] "Canada:Axel Heiberg Island" #> [141] "Canada:Ellesmere Island"