ol_geom_line: OpenLayers Line Layer

View source: R/layer_line.R

ol_geom_lineR Documentation

OpenLayers Line Layer

Description

Function to create a line layer to add to an OpenLayers Map object.

Usage

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())

Arguments

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 line.obj. Used for aestheic mapping. Defaults to line.obj@data if class(polygon.obj)==SpatialLinesDataFrame) and df is not provided.

toggle.control

logical indicating whether this layer will have a visibility toggle.

lwd

numeric line feature width. Used only if no lwd aesthetic is provided in mapping

ol.lty

(experimental) numeric vector with length > 1, or list of such vectors. Used only if no ol.lty aesthetic is provided in mapping. See OpenLayers ol/style/Stroke Documentation, 'lineDash' property for more information.

color

character line color string, or vector of color strings. Used only if no color aesthetic is provided in mapping

label

character vector of line feature labels.

label.params, tooltip.params

named lists (e.g., list(property=value)) of label and tooltip position and format parameters. See ol_geom_polygon documentation.

tooltip

character vector of line feature tooltip popups.

Details

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.

Value

A list object of class Layer.SpatialLine.

Aesthetics

See Also

ol_aes, ol_map, ol_geom_point, ol_geom_polygon, ol_geom_circle

Examples

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)

cemarks/ROpenLayers documentation built on March 31, 2022, 12:05 p.m.