@@ -119,11 +119,20 @@ tmapLeafletDataPlot.default = function(a, shpTM, dt, pdt, popup.format, hdt, idt
119119NULL
120120}
121121
122+ # preset = lapply(list(dashed = c(4, 4), dotted = c(1,3), dotdash = c(1, 3, 4, 3), longdash = c(7, 3), twodash = c(2, 2, 6, 2)), function(x) {
123+ # x * scale
124+ # })
125+ lty2dash = function (lty , lwd ) {
126+ po(lty ,lwd )
127+ k = max(length(lty ), length(lwd ))
128+ lty = rep(lty , length.out = k )
129+ lwd = rep(lwd , length.out = k )
130+
131+
122132
123- lty2dash = function (lty ) {
124133tab = c(solid = " " , dashed = " 4 4" , dotted = " 1 3" , dotdash = " 1 3 4 3" , longdash = " 7 3" , twodash = " 2 2 6 2" )
125134are_words = (lty %in% names(tab ))
126- if (all(are_words )) {
135+ x = if (all(are_words )) {
127136unname(tab [lty ])
128137} else {
129138are_letters = (suppressWarnings(! is.na(as.numeric(lty ))))
@@ -137,14 +146,25 @@ lty2dash = function(lty) {
137146lty
138147}
139148
149+ # multiply by lwd
150+ split_x <- strsplit(x , " " )
151+
152+ z = mapply(
153+ function (vals , mult ) paste(as.numeric(vals ) * mult , collapse = " " ),
154+ split_x , lwd , USE.NAMES = FALSE
155+ )
156+
157+ z [x == " " ] = " " # restore empties if needed
158+ z
140159}
141160
142161makeSymbolIcons2 = function (shape , color , fillColor = color , opacity , fillOpacity = opacity ,
143- strokeWidth = 1 , width , height = width , ... )
162+ strokeWidth = 1 , dashArray = " none " , width , height = width , ... )
144163{
145164symbols <- Map(leaflegend :: makeSymbol , shape = shape , width = width ,
146165 height = height , color = color , fillColor = fillColor ,
147166 opacity = opacity , fillOpacity = fillOpacity , `stroke-width` = strokeWidth ,
167+ `stroke-dasharray` = dashArray ,
148168 ... )
149169leaflet :: icons(iconUrl = unname(symbols ), iconAnchorX = width / 2 + strokeWidth ,
150170 iconAnchorY = height / 2 + strokeWidth )
0 commit comments