| ol_geom_line | R Documentation |
Function to create a line layer to add to an OpenLayers Map object.
ol_geom_line(line.obj, mapping = ol_aes(), name = NULL, df = NULL, toggle.control = FALSE, lwd = 1, ol.lty = list(), color = "#000000", label = NULL, label.params = list(), tooltip = NULL, tooltip.params = list())
line.obj |
SpatialLinesDataFrame, SpatialLines, list of lines-like objects, or a two-column matrix of longitude-latitude coordinates to be used as ordered line object coordinates. |
mapping |
list created by ol_aes. |
name |
character Layer name. |
df |
data.frame with same number of lines-like objects as |
toggle.control |
logical indicating whether this layer will have a visibility toggle. |
lwd |
numeric line feature width. Used only if no |
ol.lty |
(experimental) numeric vector with length > 1, or
|
color |
character line color string, or vector of color strings. Used
only if no |
label |
character vector of line feature labels. |
label.params, tooltip.params |
named lists (e.g., |
tooltip |
character vector of line feature tooltip popups. |
This function creates a list object containing the data required
to generate an OpenLayers vector layer with features using MultiLineString.
See Openlayers
MultiLineString Documentation for details.
A list object of class Layer.SpatialLine.
color
lwd
ol_lty (experimental; See OpenLayers
ol/style/Stroke Documentation,
'lineDash' property for more information.)
ol_aes, ol_map, ol_geom_point,
ol_geom_polygon, ol_geom_circle
line.matrix1 <- matrix(
c(
-80.4,-80.4,
25.78,25.88
),
ncol=2
)
line.matrix2 <- matrix(
c(
-80.25,-80.35,
25.65,25.65
),
ncol=2
)
line.list <- list(line.matrix1,line.matrix2)
line.df <- data.frame(
direction=c("vertical","horizontal"),
no=c(1,2)
)
miami.gray.basemap <- ol_map(
center=c(-80.385790,25.782618),
zoom=9
) +
lightgray()
line.layer <- ol_geom_line(
line.list,
mapping=ol_aes(
color=no,
lwd=direction
),
df=line.df,
name="Miami Lines",
toggle.control=TRUE,
tooltip=line.df$direction
)
line.color.scale <- ol_scale_color_continuous(
name="Number",
display=TRUE
)
line.width.scale <- ol_scale_lwd_discrete(
lwd.vector=c(
horizontal=2,
vertical=4
),
name="Direction",
display=TRUE
)
line.map.miami <- miami.gray.basemap +
line.layer +
line.color.scale +
line.width.scale
## Not run:
# Output to file and view
ol_map2HTML(
line.map.miami,
'miami_lines.html',
map.heading="Miami Lines"
)
browseURL("miami_lines.html")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.